From 7e6f570e496ffc71a542c04d6fd0abd50dd8b74d Mon Sep 17 00:00:00 2001 From: Vincent Hanquez Date: Wed, 8 Apr 2015 20:41:57 +0100 Subject: [PATCH] add a LE64 method --- Crypto/Internal/ByteArray.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Crypto/Internal/ByteArray.hs b/Crypto/Internal/ByteArray.hs index 4d74b93..ecdb60c 100644 --- a/Crypto/Internal/ByteArray.hs +++ b/Crypto/Internal/ByteArray.hs @@ -22,6 +22,7 @@ module Crypto.Internal.ByteArray , byteArrayToBS , byteArrayFromBS , byteArrayToW64BE + , byteArrayToW64LE ) where import Control.Applicative ((<$>)) @@ -127,3 +128,6 @@ byteArrayFromBS bs = byteArrayCopyAndFreeze bs (\_ -> return ()) byteArrayToW64BE :: ByteArrayAccess bs => bs -> Int -> Word64 byteArrayToW64BE bs ofs = unsafeDoIO $ withByteArray bs $ \p -> fromBE64 <$> peek (p `plusPtr` ofs) + +byteArrayToW64LE :: ByteArrayAccess bs => bs -> Int -> Word64 +byteArrayToW64LE bs ofs = unsafeDoIO $ withByteArray bs $ \p -> fromLE64 <$> peek (p `plusPtr` ofs)