Apero.Crypto.Random (Apero v2.1.0)

Copy Markdown View Source

Random generation utilities for cryptographic purposes.

Provides secure random generation for keys, tokens, passwords, and timing-safe comparison.

Summary

Functions

Generates a random 256-bit key.

Generates a random hex string.

Generates a random password with configurable length and character sets.

Generates a random URL-safe token.

Timing-safe string comparison.

Functions

generate_key()

@spec generate_key() :: binary()

Generates a random 256-bit key.

random_hex(bytes \\ 32)

@spec random_hex(non_neg_integer()) :: binary()

Generates a random hex string.

random_password(length \\ 24, opts \\ [])

@spec random_password(
  non_neg_integer(),
  keyword()
) :: binary()

Generates a random password with configurable length and character sets.

random_token(bytes \\ 32)

@spec random_token(non_neg_integer()) :: binary()

Generates a random URL-safe token.

secure_compare(a, b)

@spec secure_compare(binary(), binary()) :: boolean()

Timing-safe string comparison.