Skip to content

Std\Crypto

Crypto – cryptographic hashing and random byte generation.

Provides SHA-256 hashing, cryptographically secure random bytes, and UUID v4 generation.

Compute the SHA-256 hash of a string. Returns the hex-encoded digest.

import sha256 from Std\Crypto in
sha256 "hello" # => "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"

Generate n cryptographically secure random bytes, returned as a raw string.

import randomBytes from Std\Crypto in
let key = randomBytes 32 in
length key # => 32

Generate n random bytes and return them as a hex-encoded string (2n characters).

import randomHex from Std\Crypto in
randomHex 16 # => "a3f2b1..." (32 hex characters)

Generate a random UUID v4 string.

import uuid4 from Std\Crypto in
uuid4 # => "550e8400-e29b-41d4-a716-446655440000"