# ComputeHash128

> Compute a 128 bit hash based on a value. the type of the value must be a value type.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## ComputeHash128\<T>(T, Hash128)

Compute a 128 bit hash based on a value. the type of the value must be a value type.

```csharp
public static void ComputeHash128<T>(ref T value, ref Hash128 hash) where T : struct
```

### Parameters

**** (T): A reference to the value to hash.**** (\[Hash128]\(/engine/6000.0/script-reference/unityengine/hash128)): A reference to the Hash128 to updated with the computed hash.

### Examples

```csharp
using UnityEngine;
using System.Runtime.InteropServices;

public class HashUtilitiesSample
{
    [StructLayout(LayoutKind.Sequential)]
    struct TestData
    {
        public ulong V1;
        public ulong V2;
    }

    public void ComputeHash128_ToHash128()
    {
        var message = new TestData
        {
            V1 = 0x73BC2A67F,
            V2 = 0x54B1A5C2C
        };

        Hash128 hash = new Hash128();
        HashUtilities.ComputeHash128(ref message, ref hash);
    }
}
```

## ComputeHash128(byte\[], Hash128)

Compute a 128 bit hash based on a value. the type of the value must be a value type.

```csharp
public static void ComputeHash128(byte[] value, ref Hash128 hash)
```

### Parameters

**** (\[byte\[]]\(https\://learn.microsoft.com/dotnet/api/system.byte)): A reference to the value to hash.**** (\[Hash128]\(/engine/6000.0/script-reference/unityengine/hash128)): A reference to the Hash128 to updated with the computed hash.

### Examples

```csharp
using UnityEngine;
using System.Runtime.InteropServices;

public class HashUtilitiesSample
{
    [StructLayout(LayoutKind.Sequential)]
    struct TestData
    {
        public ulong V1;
        public ulong V2;
    }

    public void ComputeHash128_ToHash128()
    {
        var message = new TestData
        {
            V1 = 0x73BC2A67F,
            V2 = 0x54B1A5C2C
        };

        Hash128 hash = new Hash128();
        HashUtilities.ComputeHash128(ref message, ref hash);
    }
}
```
