Systems

vsecrets

Secure random tokens, drawn from the operating system’s own entropy.

Released v1.0.0 · 2026-09-28
Import
use "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.

vsecrets.ven
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: 8

token_urlsafe(byte_length)

Gives back a secure random URL-safe Text encoding byte_length random bytes.

print(length(token_urlsafe(4)))
:: prints: 6

randbelow(n)

print(randbelow(5) < 5)
:: prints: yes

choice(items)

Gives back a secure random element of the non-empty List items.

print(contains([1, 2, 3], choice([1, 2, 3])))
:: prints: yes

compare_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

Get notified when vsecrets changes

Get notified about

New versions and security advisories.

New and updated packages, once a day.

News on the math model built in Venutian.