entropy

A platform independent entropy source

https://github.com/TomMD/entropy

Version on this page:0.4.1.3
LTS Haskell 19.13:0.4.1.7
Stackage Nightly 2022-06-25:0.4.1.7
Latest on Hackage:0.4.1.7

See all snapshots entropy appears in

BSD-3-Clause licensed and maintained by Thomas DuBuisson
This version can be pinned in stack with:entropy-0.4.1.3@sha256:80cb7c445cd07f9834d7048021ced44f1fbd89924225e04cac2e4df0d81497e4,2617

Module documentation for 0.4.1.3

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 /dev/urandom. Hardware RNGs (currently RDRAND, patches welcome) are supported via the hardwareRNG function.

If you wish to obtain an XOR of the hardware and system RNG consider:

import           Data.Bits (xor)
import qualified Data.ByteString as B
import qualified Control.Exception as X

xorRNG sz = do hw  <- hardwareRNG sz
               h   <- openHandle
               sys <- hGetEntropy h `X.finally` closeHandle h
               pure $ B.pack $ B.zipWith xor hw sys

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.

Build Status