Skip to content

Random functions in the Crypto DuckDB extension

Function category

Random

1 function

Cryptographically secure random bytes from OpenSSL's CSPRNG. Use for encryption keys, salts, nonces, and any other cryptographic material that must be unpredictable.

crypto_random_bytes

Scalar function Random
Signature
crypto_random_bytes(length: BIGINT) BLOB
Arguments (Positional)
Argument length Type BIGINT Mode Positional Description
Description
1 32 random bytes — an AES-256 key
SELECT crypto_random_bytes(32);

Output

crypto_random_bytes(32)
a35ef22ac875491a6cd476345f91a8daef58bfa1c417eed32a98a0d7eda7f9e9
2 16-byte salt displayed as hex
SELECT lower(to_hex(crypto_random_bytes(16)));

Output

lower(to_hex(crypto_random_bytes(16)))
3f8483715eda5adabf0851568cb83642