# Module ring::rand [−] [src]

Cryptographic pseudo-random number generation.

An application should create a single `SystemRandom` and then use it for all randomness generation. Functions that generate random bytes should take a `&SecureRandom` parameter instead of instantiating their own. Besides being more efficient, this also helps document where non-deterministic (random) outputs occur. Taking a reference to a `SecureRandom` also helps with testing techniques like fuzzing, where it is useful to use a (non-secure) deterministic implementation of `SecureRandom` so that results can be replayed. Following this pattern also may help with sandboxing (seccomp filters on Linux in particular). See `SystemRandom`'s documentation for more details.

## Structs

SystemRandom | A secure random number generator where the random values come directly from the operating system.

## Traits

SecureRandom | A secure random number generator.

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)