syn.crypt.derive Synchronous

  • syn.crypto.derive

Derive a fixed-length byte string from input material with Kawaii’s HKDF-SHA-256 scheme. This is useful when one input secret must be turned into a reproducible byte sequence of a specific length.

Syntax
Luau
syn.crypt.derive(value: string, length: number) -> string

Parameters

Function parameters
ParameterTypeDescription
valuestringRaw input key material.
lengthnumberRequested number of output bytes, an integer from 0 through 8160.

Returns

string

Raw derived bytes. The same input and length produce the same output in this implementation.

Usage notes

The derived bytes are binary, not Base64 text. Use base64encode when storing them in a text-only format.

Availability

This function requires the Synapse environment setting, which is off by default.

Example

Example
Luau
local bytes = syn.crypt.derive("example seed", 32)
print(#bytes) -- 32
print(base64encode(bytes))
Kawaii documentation