From 4247520e917c79e37b5894f2a6a17aeca1c67da5 Mon Sep 17 00:00:00 2001 From: Vincent Hanquez Date: Sat, 11 Apr 2015 16:02:31 +0100 Subject: [PATCH] [Internal] add a way to index bytestring --- Crypto/Internal/ByteArray.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Crypto/Internal/ByteArray.hs b/Crypto/Internal/ByteArray.hs index eeda4bd..d7b1fbc 100644 --- a/Crypto/Internal/ByteArray.hs +++ b/Crypto/Internal/ByteArray.hs @@ -19,6 +19,7 @@ module Crypto.Internal.ByteArray , byteArraySplit , byteArrayXor , byteArrayEq + , byteArrayIndex , byteArrayConstEq , byteArrayConcat , byteArrayToBS @@ -96,6 +97,9 @@ byteArrayXor a b = la = byteArrayLength a lb = byteArrayLength b +byteArrayIndex :: ByteArrayAccess a => a -> Int -> Word8 +byteArrayIndex b i = unsafeDoIO $ withByteArray b $ \p -> peek (p `plusPtr` i) + byteArraySplit :: ByteArray bs => Int -> bs -> (bs, bs) byteArraySplit n bs | n <= 0 = (empty, bs)