3This package allows Haskell users to easily acquire entropy for use in critical
4security applications by calling out to either windows crypto api, unix/linux's
5`getrandom` and `/dev/urandom`. Hardware RNGs (currently RDRAND, patches
6welcome) are supported via the `hardwareRNG` function.
10To simply get random bytes use `getEntropy`:
15 build-depends: base, entropy, bytestring
17import qualified Data.ByteString as BS
21main = print . BS.unpack =<< getEntropy 16
22-- Example output: [241,191,215,193,225,27,121,244,16,155,252,41,131,38,6,100]
25## Faster Randoms from Hardware
27Most x86 systems include a hardware random number generator. These can be
28faster but require more trust in the platform:
31import qualified Data.ByteString as B
34eitherRNG :: Int -> IO B.ByteString
35eitherRNG sz = maybe (getEntropy sz) pure =<< getHardwareEntropy sz
38main = print . B.unpack =<< eitherRNG 32
41This package supports Windows, {li,u}nix, QNX, and has preliminary support for HaLVM.
43Typically tested on Linux and OSX - testers are as welcome as patches.
45[](https://travis-ci.org/TomMD/entropy)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list