Systems
vsecrets
Secure random tokens, drawn from the operating system’s own entropy.
Released v1.0.0 · 2026-09-28use "stdlib/secrets.ven"
Cryptographically secure randomness, built on the interpreter's own builtin that draws entropy from the real operating system rather than a pseudo random source. It is deliberately narrow: a small set of helpers for generating secure tokens and values, not a full secrets management system.
Reference (5 functions)
API reference
token_hex(byte_length)
Gives back a secure random Text of byte_length random bytes as lowercase hex.
print(length(token_hex(4)))
:: prints: 8token_urlsafe(byte_length)
Gives back a secure random URL-safe Text encoding byte_length random bytes.
print(length(token_urlsafe(4)))
:: prints: 6randbelow(n)
print(randbelow(5) < 5)
:: prints: yeschoice(items)
Gives back a secure random element of the non-empty List items.
print(contains([1, 2, 3], choice([1, 2, 3])))
:: prints: yescompare_digest(a, b)
Tests whether a and b are the same Text, with a reduced timing signal.
print(compare_digest("token123", "token123"))
print(compare_digest("token123", "token124"))
:: prints: yes
:: prints: no