GenerateBlake2sHash()

edit

Generates a Blake2s hash — the 32-bit sibling of Blake2b, designed for embedded systems and constrained environments.

For server-side use, prefer GenerateBlake2bHash() or GenerateBlake3Hash().

Requires Extension: Crypto Extension

GenerateBlake2sHash( input=any, outputLength=numeric, key=any );

Returns: String

Argument Description
input
any, required
edit

Data to hash (string or binary)

outputLength
numeric, optional
edit

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

key
any, optional
edit

Key for keyed hash mode (MAC), max 32 bytes

Examples

edit
// Blake2s is optimised for 32-bit platforms (e.g. IoT, embedded systems)
// For general-purpose hashing on servers, prefer Blake2b or Blake3
// Default output is 32 bytes (256-bit)
hash = GenerateBlake2sHash( "hello world" );

// Deterministic - same input always gives same output hash1 = GenerateBlake2sHash( "test data" ); hash2 = GenerateBlake2sHash( "test data" ); // hash1 == hash2
// Custom output length: Blake2s supports 1-32 bytes (smaller range than Blake2b) shortHash = GenerateBlake2sHash( "test", 16 ); // 16 bytes = 32 hex chars fullHash = GenerateBlake2sHash( "test", 32 ); // 32 bytes = 64 hex chars
// Keyed mode for MAC (message authentication code) key = "mysecretkey123456789012345678901"; // up to 32 bytes mac = GenerateBlake2sHash( "important data", 32, key );

See also