StormByte-Crypto 3.1.0
C++26 cryptography module of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Crypto::Random Namespace Reference

Cryptographically secure random bytes and printable text. More...

Classes

class  Exception
 Invalid random request or provider failure under StormByte.Crypto.Random. More...

Functions

Safe::SecureBinary Bytes (ByteSize count)
 Generate exactly the requested number of random octets.
Safe::String Text (Size count)
 Generate uniformly distributed printable ASCII characters.

Detailed Description

Cryptographically secure random bytes and printable text.

Calls use the existing per-thread cryptographic generator. Bytes use auto-wiped secure storage; Text returns ordinary, non-wiped text.

Function Documentation

◆ Bytes()

Safe::SecureBinary StormByte::Crypto::Random::Bytes ( ByteSize count)

Generate exactly the requested number of random octets.

Parameters
countNumber of bytes. Must be greater than zero.
Returns
Independently owned, fully generated bytes in auto-wiped storage.
Exceptions
ExceptionThe count is zero or the cryptographic provider failed.
Note
Allocation errors propagate unchanged. No partial result is returned on failure; temporary provider storage is securely wiped. Memory locking is best effort, not a guarantee against swapping. Moving or swapping the result into a plain Safe::Binary loses its wiping and locking guarantees; copies through borrowed views are the caller's responsibility.

◆ Text()

Safe::String StormByte::Crypto::Random::Text ( Size count)

Generate uniformly distributed printable ASCII characters.

Parameters
countNumber of characters. Must be greater than zero.
Returns
Independently owned text of exactly count characters in ASCII 33 through 126 inclusive (no spaces or embedded NUL).
Exceptions
ExceptionThe count is zero or the cryptographic provider failed.
Note
Sampling is unbiased. Allocation errors propagate unchanged. No partial result is returned on failure; temporary provider storage is securely wiped. The trailing NUL is not part of the length. Returned text is not automatically wiped or memory-locked.