vincenthz / hs-cryptohash

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

md5 outputs strange bytestring #2

Closed aycanirican closed 13 years ago

aycanirican commented 13 years ago

fxr@fxr-desktop:~$ ghc-pkg list | grep crypto crypto-api-0.6.1 cryptocipher-0.2.12 cryptohash-0.7.0

fxr@fxr-desktop:~$ ghci GHCi, version 7.0.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Loading package ffi-1.0 ... linking ... done. Prelude> :m +Crypto.Hash.MD5 Prelude Crypto.Hash.MD5> :m +Data.ByteString.Char8 Prelude Crypto.Hash.MD5 Data.ByteString.Char8> hash (pack "test") Loading package array-0.3.0.2 ... linking ... done. Loading package containers-0.4.0.0 ... linking ... done. Loading package bytestring-0.9.1.10 ... linking ... done. Loading package cereal-0.3.3.0 ... linking ... done. Loading package largeword-1.0.0 ... linking ... done. Loading package data-default-0.2.0.1 ... linking ... done. Loading package semigroups-0.5.0 ... linking ... done. Loading package tagged-0.2.2 ... linking ... done. Loading package crypto-api-0.6.1 ... linking ... done. Loading package cryptohash-0.7.0 ... linking ... done. "\t\143k\205F!\211s\202\222N\131&'\180\246" Prelude Crypto.Hash.MD5 Data.ByteString.Char8> :q Leaving GHCi.

vincenthz commented 13 years ago

hi aycanirican,

the output is the packed version of the md5 which is correct. the pack hash is usually the one getting sent, stored or passed around as it is shorter. To turn it in an hexadecimal version, which is usually the one displayed, you can use the same kind of function as the hexalise function in Tests.hs