summaryrefslogtreecommitdiffhomepage
path: root/ByteStrings.hs
diff options
context:
space:
mode:
Diffstat (limited to 'ByteStrings.hs')
-rw-r--r--ByteStrings.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/ByteStrings.hs b/ByteStrings.hs
index 02e22ab..cecf617 100644
--- a/ByteStrings.hs
+++ b/ByteStrings.hs
@@ -1,3 +1,5 @@
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
{- Copyright 2016 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
@@ -6,6 +8,9 @@
module ByteStrings where
import qualified Data.ByteString as B
+import qualified Raaz
+import Control.Monad
+import Data.Word
allByteStringsOfLength :: Int -> [B.ByteString]
allByteStringsOfLength = go []
@@ -28,3 +33,10 @@ chunkByteString n = go []
| otherwise =
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
+ where
+ randbyte = Raaz.random prg :: IO Word8