forked from schmittlauch/Hash2Pub
debugged computation bug in ByteString to UInteger conversion
likely caused by an overflow, but don't have time to investigate
This commit is contained in:
parent
2d05d0644d
commit
b41acaf52a
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue