syn.crypt.derive Synchronous

  • syn.crypto.derive

Derive a byte string from input material using the compatibility library’s HKDF-SHA-256 derivation. Use it to expand existing key material into a reproducible byte sequence. Derivation is not random generation and does not turn a weak password into a strong secret.

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

Parameters

Function parameters
ParameterTypeDescription
valuestringInput key material.
lengthnumberRequested output length in bytes, as an integer from 0 through 8160.

Returns

string

Raw derived bytes. Identical input and length produce the same output.

Availability

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

Example

Example
Luau
-- Enable the Synapse environment setting first.
local material = syn.crypt.random(32)
local derived = syn.crypt.derive(material, 32)
print(#derived) -- 32
print(derived == syn.crypt.derive(material, 32)) -- true
Kawaii documentation