>> import qualified Data.ByteString as B
-- >>> import Test.QuickCheck

-- | Generate a random bytestring of length n. The PRNG is seeded
-- from the system randomness source.
--
-- prop> ioProperty $ ((fromIntegral n ===) . B.length) <$> random n
-- prop> n > 4 ==> ioProperty $ (/=) <$> random n <*> random n
--
random
    ∷ Natural
        -- ^ Length of the result bytestring in bytes
    → IO ByteString
random = withSystemRandom . flip randomGen


random
    ∷ Natural
        -- ^ Length of the result bytestring in bytes
    → IO ByteString
random = withSystemRandom . flip randomGen
random = withSystemRandom . flip randomGen