W3cubDocs

/Crystal 0.31

module Random::Secure

Overview

Generates random numbers from a secure source provided by the system.

For example arc4random is used on OpenBSD, whereas on Linux it uses getrandom (if the kernel supports it) and fallbacks on reading from /dev/urandom on UNIX systems.

Random::Secure.rand(6)            # => 4
[1, 5, 6].shuffle(Random::Secure) # => [6, 1, 5]

Extended Modules

Defined in:

random/secure.cr

Instance Method Summary

Instance Method Detail

def next_uSource

def random_bytes(buf : Bytes)Source

© 2012–2019 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.31.1/Random/Secure.html