Produce cryptographically secure tokens for magic links, session identifiers, and other authentication flows where unpredictability is critical. Uses OpenSSL's cryptographically secure random number generator. Call this when creating magic link tokens, session IDs, or any security-sensitive random values that must be unguessable.
Value
Character string containing the hex-encoded token (2x length chars). For example, length=32 returns a 64-character hex string suitable for magic links or session tokens.
See also
Other security:
hash_token(),
is_valid_email(),
security
Examples
if (FALSE) { # \dontrun{
# Generate a token for a magic link
token <- generate_secure_token(32)
print(nchar(token)) # 64 hex characters
# Store the hashed version in the database
hashed <- hash_token(token)
} # }
