Skip to content

Random Number Generation

Tony Arcieri edited this page May 6, 2016 · 3 revisions

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/urandom on Unix-based operating systems and CryptGenRandom on Windows.

Example

# random strings
RbNaCl::Random.random_bytes(32)
#=> 32 bytes of randomness, from the OS
Clone this wiki locally