| CARVIEW |
entropy: A platform independent entropy source
A mostly platform independent method to obtain cryptographically strong entropy
(RDRAND, urandom, CryptAPI, and patches welcome)
Users looking for cryptographically strong (number-theoretically
sound) PRNGs should see the DRBG package too.
[Skip to Readme]
Flags
Manual Flags
| Name | Description | Default |
|---|---|---|
| donotgetentropy | Avoid use of the getentropy() *nix function. By default getentropy will be used if detected during compilation (this plays poorly with cross compilation). | Disabled |
Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info
Downloads
- entropy-0.4.1.11.tar.gz [browse] (Cabal source package)
- Package description (revised from the package)
Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
| Versions [RSS] | 0.1, 0.2, 0.2.1, 0.2.2, 0.2.2.1, 0.2.2.2, 0.2.2.3, 0.2.2.4, 0.3, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.4.1, 0.3.5, 0.3.6, 0.3.7, 0.3.8, 0.4, 0.4.1, 0.4.1.1, 0.4.1.2, 0.4.1.3, 0.4.1.4, 0.4.1.5, 0.4.1.6, 0.4.1.7, 0.4.1.9, 0.4.1.10, 0.4.1.11 |
|---|---|
| Dependencies | base (>=4.8 && <5), bytestring, ghcjs-dom (>=0.9.5.0 && <1), jsaddle, unix, Win32 (>=2.5) [details] |
| Tested with | ghc ==9.14.1, ghc ==9.12.1, ghc ==9.10.1, ghc ==9.8.4, ghc ==9.6.6, ghc ==9.4.8, ghc ==9.2.8, ghc ==9.0.2, ghc ==8.10.7, ghc ==8.8.4, ghc ==8.6.5, ghc ==8.4.4, ghc ==8.2.2 |
| License | BSD-3-Clause |
| Copyright | Thomas DuBuisson <thomas.dubuisson@gmail.com> |
| Author | Thomas DuBuisson <thomas.dubuisson@gmail.com> |
| Maintainer | Thomas DuBuisson <thomas.dubuisson@gmail.com> |
| Uploaded | by ThomasDuBuisson at 2025-01-01T23:24:19Z |
| Revised | Revision 1 made by AndreasAbel at 2026-01-09T08:21:53Z |
| Category | Data, Cryptography |
| Home page | https://github.com/TomMD/entropy |
| Bug tracker | https://github.com/TomMD/entropy/issues |
| Source repo | head: git clone https://github.com/TomMD/entropy |
| Distributions | Arch:0.4.1.11, Debian:0.4.1.6, Fedora:0.4.1.11, FreeBSD:0.3.7, LTSHaskell:0.4.1.11, NixOS:0.4.1.11, Stackage:0.4.1.11, openSUSE:0.4.1.11 |
| Reverse Dependencies | 55 direct, 3672 indirect [details] |
| Downloads | 154787 total (146 in the last 30 days) |
| Rating | (no votes yet) [estimated by Bayesian average] |
| Your Rating |
|
| Status | Docs available [build log] Last success reported on 2025-01-02 [all 1 reports] |
Readme for entropy-0.4.1.11
[back to package description]Introduction
This package allows Haskell users to easily acquire entropy for use in critical
security applications by calling out to either windows crypto api, unix/linux's
getrandom and /dev/urandom. Hardware RNGs (currently RDRAND, patches
welcome) are supported via the hardwareRNG function.
Quick Start
To simply get random bytes use getEntropy:
#!/usr/bin/env cabal
{- cabal:
build-depends: base, entropy, bytestring
-}
import qualified Data.ByteString as BS
import System.Entropy
main :: IO ()
main = print . BS.unpack =<< getEntropy 16
-- Example output: [241,191,215,193,225,27,121,244,16,155,252,41,131,38,6,100]
Faster Randoms from Hardware
Most x86 systems include a hardware random number generator. These can be faster but require more trust in the platform:
import qualified Data.ByteString as B
import System.Entropy
eitherRNG :: Int -> IO B.ByteString
eitherRNG sz = maybe (getEntropy sz) pure =<< getHardwareEntropy sz
main :: IO ()
main = print . B.unpack =<< eitherRNG 32
This package supports Windows, {li,u}nix, QNX, and has preliminary support for HaLVM.
Typically tested on Linux and OSX - testers are as welcome as patches.