summaryrefslogtreecommitdiffhomepage
path: root/ByteStrings.hs
diff options
context:
space:
mode:
Diffstat (limited to 'ByteStrings.hs')
-rw-r--r--ByteStrings.hs13
1 files changed, 4 insertions, 9 deletions
diff --git a/ByteStrings.hs b/ByteStrings.hs
index cecf617..90b42f0 100644
--- a/ByteStrings.hs
+++ b/ByteStrings.hs
@@ -1,5 +1,3 @@
-{-# OPTIONS_GHC -fno-warn-orphans #-}
-
{- Copyright 2016 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
@@ -9,8 +7,6 @@ module ByteStrings where
import qualified Data.ByteString as B
import qualified Raaz
-import Control.Monad
-import Data.Word
allByteStringsOfLength :: Int -> [B.ByteString]
allByteStringsOfLength = go []
@@ -34,9 +30,8 @@ chunkByteString n = go []
let (h, t) = B.splitAt n b
in go (h:cs) t
-instance Raaz.Random Word8
-
-randomByteStringOfLength :: Int -> Raaz.SystemPRG -> IO B.ByteString
-randomByteStringOfLength n prg = B.pack <$> replicateM n randbyte
+randomByteStringOfLength :: Int -> IO B.ByteString
+randomByteStringOfLength n = Raaz.securely gen
where
- randbyte = Raaz.random prg :: IO Word8
+ gen :: Raaz.RandM B.ByteString
+ gen = Raaz.randomByteString (Raaz.BYTES n)