ripemd160

Pure Haskell RIPEMD-160, HMAC-RIPEMD160 (docs.ppad.tech/ripemd160).
git clone git://git.ppad.tech/ripemd160.git
Log | Files | Refs | README | LICENSE

Main.hs (801B)


      1 {-# LANGUAGE OverloadedStrings #-}
      2 
      3 module Main where
      4 
      5 import Criterion.Main
      6 import qualified Crypto.Hash.RIPEMD160 as RIPEMD160
      7 import qualified Data.ByteString as BS
      8 import qualified Data.ByteString.Lazy as BL
      9 
     10 main :: IO ()
     11 main = defaultMain [
     12     suite
     13   ]
     14 
     15 suite :: Benchmark
     16 suite = env setup $ \ ~(bs, bl) ->
     17     bgroup "ppad-ripemd160" [
     18       bgroup "RIPEMD160 (32B input)" [
     19         bench "hash" $ whnf RIPEMD160.hash bs
     20       , bench "hash_lazy" $ whnf RIPEMD160.hash_lazy bl
     21       ]
     22     , bgroup "HMAC-RIPEMD160 (32B input)" [
     23         bench "hmac" $ whnf (RIPEMD160.hmac "key") bs
     24       , bench "hmac_lazy" $ whnf (RIPEMD160.hmac_lazy "key") bl
     25       ]
     26     ]
     27   where
     28     setup = do
     29       let bs_32B = BS.replicate 32 0
     30           bl_32B = BL.fromStrict bs_32B
     31       pure (bs_32B, bl_32B)
     32