Safe Haskell | None |
---|---|
Language | Haskell2010 |
Support for generation of cryptographically secure random numbers, based on the DRBG package.
This is a convenience layer on top of DRBG, which allows you to
pull random values by means of the method random
, while keeping
the state of the random number generator (RNG) inside a monad. The
state is protected by an MVar, which means that concurrent
generation of random values from several threads works straight out
of the box.
The access to the RNG state is captured by a class. By making instances of this class, client code can enjoy RNG generation from their own monads.
Synopsis
- module Crypto.RNG.Class
- data CryptoRNGState
- newCryptoRNGState :: MonadIO m => m CryptoRNGState
- newCryptoRNGStateSized :: MonadIO m => Int -> m CryptoRNGState
- unsafeCryptoRNGState :: MonadIO m => [ByteString] -> m CryptoRNGState
- randomBytesIO :: ByteLength -> CryptoRNGState -> IO ByteString
- randomIO :: Uniform a => CryptoRNGState -> IO a
- randomRIO :: UniformRange a => (a, a) -> CryptoRNGState -> IO a
- data CryptoRNGT m a
- mapCryptoRNGT :: (m a -> n b) -> CryptoRNGT m a -> CryptoRNGT n b
- runCryptoRNGT :: CryptoRNGState -> CryptoRNGT m a -> m a
- withCryptoRNGState :: (CryptoRNGState -> m a) -> CryptoRNGT m a
CryptoRNG class
module Crypto.RNG.Class
Generation of strings and numbers
data CryptoRNGState Source #
The random number generator state.
newCryptoRNGState :: MonadIO m => m CryptoRNGState Source #
Create a new CryptoRNGState
, based on system entropy.
newCryptoRNGStateSized Source #
:: MonadIO m | |
=> Int | Pool size. |
-> m CryptoRNGState |
Create a new CryptoRNGState
, based on system entropy with the pool of a
specific size.
:: MonadIO m | |
=> [ByteString] | Seeds for each generator from the pool. |
-> m CryptoRNGState |
Create a new CryptoRNGState
, based on a bytestring seed.
Should only be used for testing.
:: ByteLength | number of bytes to generate |
-> CryptoRNGState | |
-> IO ByteString |
Generate given number of cryptographically secure random bytes.
randomRIO :: UniformRange a => (a, a) -> CryptoRNGState -> IO a Source #
Monad transformer for carrying rng state
data CryptoRNGT m a Source #
Monad transformer with RNG state.
Instances
mapCryptoRNGT :: (m a -> n b) -> CryptoRNGT m a -> CryptoRNGT n b Source #
runCryptoRNGT :: CryptoRNGState -> CryptoRNGT m a -> m a Source #
withCryptoRNGState :: (CryptoRNGState -> m a) -> CryptoRNGT m a Source #