logo
Expand description

Secure random number generator interface.

This module implements the SecureRandom package from the Ruby Standard Library. It is an interface to secure random number generators which are suitable for generating session keys in HTTP cookies, etc.

You can use this library in your application by requiring it:

require 'securerandom'

This implementation of SecureRandom supports the system RNG via the getrandom crate. This implementation does not depend on OpenSSL.

Modules

FFI glue between the Rust trampolines and the mruby C interpreter.

Glue between mruby FFI and securerandom Rust implementation.

Structs

Error that indicates an argument parsing or value logic error occurred.

Error that indicates the given maximum value is not finite and cannot be used to bound a domain for generating random numbers.

Error that indicates the underlying source of randomness failed to generate the requested random bytes.

A handle to the underlying secure random number generator.

Enums

Max value when generating a random number from a range.

Random numeric value generated from the secure random number generator.

Sum type of all errors possibly returned from random_bytes.

Functions

Generate a random sequence of ASCII alphanumeric bytes.

Generate a base64-encoded String of random bytes.

Generate a hex-encoded String of random bytes.

Generate a vector of random bytes.

Generate a single random number, either a float or an integer.

Generate a URL-safe base64-encoded String of random bytes.

Generate a version 4 UUID and return a String.