From b41acaf52aecd1f2251b5319529453556dea1b56 Mon Sep 17 00:00:00 2001 From: Trolli Schmittlauch Date: Fri, 20 Mar 2020 01:21:00 +0100 Subject: [PATCH] debugged computation bug in ByteString to UInteger conversion likely caused by an overflow, but don't have time to investigate --- Hash2Pub/hashtest.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Hash2Pub/hashtest.hs b/Hash2Pub/hashtest.hs index 3d0723d..9b866e5 100644 --- a/Hash2Pub/hashtest.hs +++ b/Hash2Pub/hashtest.hs @@ -3,7 +3,6 @@ module Foo where import Crypto.Hash import Data.Word -import Data.Bits (shift) import Network.Socket (HostAddress6) import qualified Data.ByteString as BS import qualified Data.ByteString.Builder as BB @@ -46,7 +45,7 @@ byteStringToUInteger bs = sum $ parsedBytes 0 bs parseWithOffset :: Integer -> Word8 -> Integer parseWithOffset 0 word = toInteger word -- a shift of 0 is always 0 - parseWithOffset offset word = shift (toInteger word) 8*offset + parseWithOffset offset word = toInteger word * 2^(8 * offset) -- |Utility function creating a strict ByteString from [Word32], -- needed for encoding @HostAddress6@ as a ByteString