# Hash128

> Compute a 128bits hash of a memory region

## Definition

* **Type:** Method
* **Namespace:** [Unity.Collections](/engine/6000.7/script-reference/unity/collections.md)
* **Assembly:** UnityEngine.ManagedKernelModule

## Hash128(void\*, long)

Compute a 128bits hash of a memory region

```csharp
public static uint4 Hash128(void* input, long length)
```

### Parameters

**** (\[void\*]\(https\://learn.microsoft.com/dotnet/api/system.void)): The memory buffer, can't be null**** (\[long]\(https\://learn.microsoft.com/dotnet/api/system.int64)): The length of the memory buffer, can be zero

### Returns

| Type                                                                | Description     |
| ------------------------------------------------------------------- | --------------- |
| [uint4](/engine/6000.7/script-reference/unity/mathematics/uint4.md) | The hash result |

## Hash128\<T>(T)

Compute a 128bits hash from the contents of the input struct

```csharp
public static uint4 Hash128<T>(in T input) where T : unmanaged
```

### Parameters

**** (T): The input struct that will be hashed

### Returns

| Type                                                                | Description     |
| ------------------------------------------------------------------- | --------------- |
| [uint4](/engine/6000.7/script-reference/unity/mathematics/uint4.md) | The hash result |

## Hash128(void\*, void\*, long)

Compute a 128bits hash while copying the data to a destination buffer

```csharp
public static uint4 Hash128(void* input, void* destination, long length)
```

### Parameters

**** (\[void\*]\(https\://learn.microsoft.com/dotnet/api/system.void)): The memory buffer to compute the hash and copy from, can't be null**** (\[void\*]\(https\://learn.microsoft.com/dotnet/api/system.void)): The destination buffer, can't be null and must be at least big enough to match the input's length**** (\[long]\(https\://learn.microsoft.com/dotnet/api/system.int64)): The length of the memory buffer, can be zero

### Returns

| Type                                                                | Description     |
| ------------------------------------------------------------------- | --------------- |
| [uint4](/engine/6000.7/script-reference/unity/mathematics/uint4.md) | The hash result |

### Remarks

Use this API to avoid a double memory scan in situations where the hash as to be compute and the data copied at the same time. Performances improvements vary between 30-50% on big data.

## Hash128(void\*, long, ulong)

Compute a 128bits hash of a memory region using a given seed value

```csharp
public static uint4 Hash128(void* input, long length, ulong seed)
```

### Parameters

**** (\[void\*]\(https\://learn.microsoft.com/dotnet/api/system.void)): The memory buffer, can't be null**** (\[long]\(https\://learn.microsoft.com/dotnet/api/system.int64)): The length of the memory buffer, can be zero**** (\[ulong]\(https\://learn.microsoft.com/dotnet/api/system.uint64)): The seed value to alter the hash computation from

### Returns

| Type                                                                | Description     |
| ------------------------------------------------------------------- | --------------- |
| [uint4](/engine/6000.7/script-reference/unity/mathematics/uint4.md) | The hash result |

## Hash128(void\*, void\*, long, ulong)

Compute a 128bits hash while copying the data to a destination buffer using a given seed value

```csharp
public static uint4 Hash128(void* input, void* destination, long length, ulong seed)
```

### Parameters

**** (\[void\*]\(https\://learn.microsoft.com/dotnet/api/system.void)): The memory buffer to compute the hash and copy from, can't be null**** (\[void\*]\(https\://learn.microsoft.com/dotnet/api/system.void)): The destination buffer, can't be null and must be at least big enough to match the input's length**** (\[long]\(https\://learn.microsoft.com/dotnet/api/system.int64)): The length of the memory buffer, can be zero**** (\[ulong]\(https\://learn.microsoft.com/dotnet/api/system.uint64)): The seed value to alter the hash computation from

### Returns

| Type                                                                | Description     |
| ------------------------------------------------------------------- | --------------- |
| [uint4](/engine/6000.7/script-reference/unity/mathematics/uint4.md) | The hash result |
