std.salt

std

salt(length) -> salt

Generate a random binary salt string

Returns a string of length random bytes (default 16) from the kernel CSPRNG. The output is raw binary, NOT hex-encoded. Byte value 0x00 is excluded. Suitable for use as HMAC key material or a password-hashing salt.

Returns nil, err if the kernel entropy source cannot be read. Callers must not paper over that: a salt that silently degrades is the failure this function exists to prevent.