vincenthz / hs-cryptohash

efficient and practical cryptohashing in haskell. DEPRECATED in favor of cryptonite
Other
30 stars 24 forks source link

Doc fixes: issue with [1..256] in the example #15

Closed mignon-p closed 11 years ago

mignon-p commented 11 years ago

I was trying out this example from the cryptohash documentation:

import qualified Crypto.Hash.SHA1 as SHA1

main = putStrLn $ show $ SHA1.hash (Data.ByteString.pack [1..256])

and I was puzzled because it seemed to be using a zero-length bytestring. That turns out to be the case, because Data.ByteString.pack takes a [Word8], and:

[1..256] :: [Word8]

is the same as:

[1..0] :: [Word8]

which is the same as:

[] :: [Word8]

I assume the intent was to hash 256 bytes, so I've submitted a patch to hash [0..255] instead of [1..256].

vincenthz commented 11 years ago

Thanks