> ## Documentation Index
> Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# crypto/Blake2

> Auto-generated API documentation

[**@tevm/voltaire**](../index.mdx)

***

[@tevm/voltaire](../index.mdx) / crypto/Blake2

# crypto/Blake2

## Variables

### ~~Blake2~~

> `const` **Blake2**: (`input`, `outputLength?`) => [`Blake2Hash`](../index/index.mdx#blake2hash) & `object` = `Blake2Hash`

Defined in: [src/crypto/Blake2/Blake2.js:51](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/Blake2/Blake2.js#L51)

#### Type Declaration

##### ~~from()~~

> **from**: (`input`, `outputLength?`) => [`Blake2Hash`](../index/index.mdx#blake2hash)

Hash input with BLAKE2b (constructor pattern)

Auto-detects input type and hashes accordingly:

* Uint8Array: hash directly
* string: UTF-8 encode then hash

###### Parameters

###### input

Data to hash

`string` | `Uint8Array`\<`ArrayBufferLike`>

###### outputLength?

`number` = `64`

Output length in bytes (1-64, default 64)

###### Returns

[`Blake2Hash`](../index/index.mdx#blake2hash)

BLAKE2b hash

###### See

[https://voltaire.tevm.sh/crypto/blake2](https://voltaire.tevm.sh/crypto/blake2) for crypto documentation

###### Since

0.0.0

###### Throws

If outputLength is invalid

###### Example

```javascript theme={null}
import { Blake2Hash } from './crypto/Blake2/index.js';

const hash1 = Blake2Hash.from("hello");              // String, 64 bytes
const hash2 = Blake2Hash.from("hello", 32);          // String, 32 bytes
const hash3 = Blake2Hash.from(uint8array);           // Bytes, 64 bytes
const hash4 = Blake2Hash.from(uint8array, 48);       // Bytes, 48 bytes
```

##### ~~fromString()~~

> **fromString**: (`str`, `outputLength?`) => [`Blake2Hash`](../index/index.mdx#blake2hash) = `hashString`

Hash string with BLAKE2b (convenience function)

###### Parameters

###### str

`string`

Input string to hash

###### outputLength?

`number` = `64`

Output length in bytes (1-64, default 64)

###### Returns

[`Blake2Hash`](../index/index.mdx#blake2hash)

BLAKE2b hash

###### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

###### Since

0.0.0

###### Throws

If outputLength is invalid

###### Example

```javascript theme={null}
import * as Blake2 from './crypto/Blake2/index.js';
const hash = Blake2.hashString("hello world");
const hash48 = Blake2.hashString("hello world", 48);
```

##### ~~hash()~~

> **hash**: (`data`, `outputLength?`) => [`Blake2Hash`](../index/index.mdx#blake2hash)

Hash data with BLAKE2b

###### Parameters

###### data

Input data to hash (Uint8Array or string)

`string` | `Uint8Array`\<`ArrayBufferLike`>

###### outputLength?

`number` = `64`

Output length in bytes (1-64, default 64)

###### Returns

[`Blake2Hash`](../index/index.mdx#blake2hash)

BLAKE2b hash

###### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

###### Since

0.0.0

###### Throws

If outputLength is invalid

###### Example

```javascript theme={null}
import * as Blake2 from './crypto/Blake2/index.js';
const hash = Blake2.hash(new Uint8Array([1, 2, 3]));
const hash32 = Blake2.hash("hello", 32);
```

##### ~~hashString()~~

> **hashString**: (`str`, `outputLength?`) => [`Blake2Hash`](../index/index.mdx#blake2hash)

Hash string with BLAKE2b (convenience function)

###### Parameters

###### str

`string`

Input string to hash

###### outputLength?

`number` = `64`

Output length in bytes (1-64, default 64)

###### Returns

[`Blake2Hash`](../index/index.mdx#blake2hash)

BLAKE2b hash

###### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

###### Since

0.0.0

###### Throws

If outputLength is invalid

###### Example

```javascript theme={null}
import * as Blake2 from './crypto/Blake2/index.js';
const hash = Blake2.hashString("hello world");
const hash48 = Blake2.hashString("hello world", 48);
```

##### ~~SIZE~~

> **SIZE**: `number`

#### Deprecated

Use Blake2Hash instead
Blake2 alias maintained for backward compatibility

***

### SIZE

> `const` **SIZE**: `64` = `64`

Defined in: [src/crypto/Blake2/Blake2HashType.ts:23](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/Blake2/Blake2HashType.ts#L23)

## Functions

### compress()

> **compress**(`input`): `Uint8Array`\<`ArrayBufferLike`>

Defined in: [src/crypto/Blake2/compress.js:41](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/Blake2/compress.js#L41)

BLAKE2b F compression function (EIP-152 format)

#### Parameters

##### input

`Uint8Array`\<`ArrayBufferLike`>

213-byte input in EIP-152 format

#### Returns

`Uint8Array`\<`ArrayBufferLike`>

64-byte output (updated state)

#### Throws

If input length is not 213 bytes

#### Example

```javascript theme={null}
import { compress } from './crypto/Blake2/compress.js';

const input = new Uint8Array(213);
// ... fill input with rounds, h, m, t, f
const output = compress(input);
```

***

### from()

> **from**(`input`, `outputLength?`): [`Blake2Hash`](../index/index.mdx#blake2hash)

Defined in: [src/crypto/Blake2/from.js:27](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/Blake2/from.js#L27)

Hash input with BLAKE2b (constructor pattern)

Auto-detects input type and hashes accordingly:

* Uint8Array: hash directly
* string: UTF-8 encode then hash

#### Parameters

##### input

Data to hash

`string` | `Uint8Array`\<`ArrayBufferLike`>

##### outputLength?

`number` = `64`

Output length in bytes (1-64, default 64)

#### Returns

[`Blake2Hash`](../index/index.mdx#blake2hash)

BLAKE2b hash

#### See

[https://voltaire.tevm.sh/crypto/blake2](https://voltaire.tevm.sh/crypto/blake2) for crypto documentation

#### Since

0.0.0

#### Throws

If outputLength is invalid

#### Example

```javascript theme={null}
import { Blake2Hash } from './crypto/Blake2/index.js';

const hash1 = Blake2Hash.from("hello");              // String, 64 bytes
const hash2 = Blake2Hash.from("hello", 32);          // String, 32 bytes
const hash3 = Blake2Hash.from(uint8array);           // Bytes, 64 bytes
const hash4 = Blake2Hash.from(uint8array, 48);       // Bytes, 48 bytes
```

***

### hash()

> **hash**(`data`, `outputLength?`): [`Blake2Hash`](../index/index.mdx#blake2hash)

Defined in: [src/crypto/Blake2/hash.js:19](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/Blake2/hash.js#L19)

Hash data with BLAKE2b

#### Parameters

##### data

Input data to hash (Uint8Array or string)

`string` | `Uint8Array`\<`ArrayBufferLike`>

##### outputLength?

`number` = `64`

Output length in bytes (1-64, default 64)

#### Returns

[`Blake2Hash`](../index/index.mdx#blake2hash)

BLAKE2b hash

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

#### Throws

If outputLength is invalid

#### Example

```javascript theme={null}
import * as Blake2 from './crypto/Blake2/index.js';
const hash = Blake2.hash(new Uint8Array([1, 2, 3]));
const hash32 = Blake2.hash("hello", 32);
```

***

### hashString()

> **hashString**(`str`, `outputLength?`): [`Blake2Hash`](../index/index.mdx#blake2hash)

Defined in: [src/crypto/Blake2/hashString.js:19](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/crypto/Blake2/hashString.js#L19)

Hash string with BLAKE2b (convenience function)

#### Parameters

##### str

`string`

Input string to hash

##### outputLength?

`number` = `64`

Output length in bytes (1-64, default 64)

#### Returns

[`Blake2Hash`](../index/index.mdx#blake2hash)

BLAKE2b hash

#### See

[https://voltaire.tevm.sh/crypto](https://voltaire.tevm.sh/crypto) for crypto documentation

#### Since

0.0.0

#### Throws

If outputLength is invalid

#### Example

```javascript theme={null}
import * as Blake2 from './crypto/Blake2/index.js';
const hash = Blake2.hashString("hello world");
const hash48 = Blake2.hashString("hello world", 48);
```

## References

### Blake2Hash

Re-exports [Blake2Hash](../index/index.mdx#blake2hash)
