Safe Haskell | None |
---|---|
Language | Haskell2010 |
Support for generation of cryptographically secure random numbers.
This is a convenience layer on top of System.Entropy, which allows you to
pull random values by means of the class CryptoRNG
, 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.
Synopsis
- module Crypto.RNG.Class
- 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
- data CryptoRNGState
- newCryptoRNGState :: MonadIO m => m CryptoRNGState
- newCryptoRNGStateSized :: MonadIO m => Int -> m CryptoRNGState
- randomBytesIO :: Int -> CryptoRNGState -> IO ByteString
CryptoRNG class
module Crypto.RNG.Class
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 #
Instantiation of the initial RNG state
data CryptoRNGState Source #
The random number generator state.
Instances
StatefulGen CryptoRNGState IO Source # | |
Defined in Crypto.RNG uniformWord32R :: Word32 -> CryptoRNGState -> IO Word32 # uniformWord64R :: Word64 -> CryptoRNGState -> IO Word64 # uniformWord8 :: CryptoRNGState -> IO Word8 # uniformWord16 :: CryptoRNGState -> IO Word16 # uniformWord32 :: CryptoRNGState -> IO Word32 # uniformWord64 :: CryptoRNGState -> IO Word64 # uniformShortByteString :: Int -> CryptoRNGState -> IO ShortByteString # |
newCryptoRNGState :: MonadIO m => m CryptoRNGState Source #
Create a new CryptoRNGState
based on system entropy with a buffer size of
32KB.
newCryptoRNGStateSized Source #
:: MonadIO m | |
=> Int | Buffer size. |
-> m CryptoRNGState |
Create a new CryptoRNGState
based on system entropy with a buffer of
specified size.
Low-level utils
randomBytesIO :: Int -> CryptoRNGState -> IO ByteString Source #
Generate a number of cryptographically secure random bytes.