Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Random Number Generation

Tony Arcieri edited this page · 1 revision

Cryptography often depends on your ability to create secure numbers, but doing that correctly is surprisingly hard! RbNaCl tries to get that right for you, by using /dev/random on Unix-based operating systems and CryptGenRandom on Windows.

Example

# random strings
RbNaCl::Random.random_bytes(32)
#=> 32 bytes of randomness, from the OS
Something went wrong with that request. Please try again.