blakesum 0.2 → 0.3
raw patch · 4 files changed
+50/−29 lines, 4 filesdep +textsetup-changedPVP ok
version bump matches the API change (PVP)
Dependencies added: text
API changes (from Hackage documentation)
+ Data.Digest.SHA3.Candidate.BLAKE: textDigest :: ByteString -> Text
Files
- Data/Digest/SHA3/Candidate/BLAKE.hs +43/−24
- Setup.hs +2/−0
- Setup.lhs +0/−3
- blakesum.cabal +5/−2
Data/Digest/SHA3/Candidate/BLAKE.hs view
@@ -1,21 +1,34 @@--- Copyright (c) 2011 Kevin Cantu <me@kevincantu.org>+-- |+-- Copyright : (c) 2011 Kevin Cantu ----- A naive implementation of the Blake cryptographic hash: --- use at your own risk.--{-# LANGUAGE BangPatterns #-}-+-- Module : Data.Digest.SHA3.Candidate.BLAKE+-- License : BSD-style+-- Maintainer : Kevin Cantu <me@kevincantu.org>+-- Stability : experimental+-- -- | BLAKE is one of the finalists in the NIST SHA-3 hash function competition -- to replace SHA-1 and SHA-2. -module Data.Digest.SHA3.Candidate.BLAKE ( blake256, blake512, blake224, blake384 ) where+module Data.Digest.SHA3.Candidate.BLAKE ( + -- * Digests+ blake256+ , blake512+ , blake224+ , blake384 + -- * Simple display+ , textDigest + ) where++ import Data.Bits import Data.Word import Data.Int import Data.List import qualified Data.ByteString.Lazy as B import qualified Data.Vector.Storable as V+import qualified Data.Text.Lazy as T+import qualified Text.Printf as P --import Control.Parallel.Strategies @@ -94,15 +107,6 @@ 0x0801F2E2858EFC16, 0x636920D871574E69 ] -{--test2d :: V.Vector [ Int ]-test2d =- V.fromList [[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ] - ,[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ] - ]--}-- -- BLAKE-256 permutations of {0..15} sigmaTable :: [ V.Vector Int ] sigmaTable =@@ -180,17 +184,17 @@ -- apply G to columns -- then rotate result back into order- applyColumns [s00,s01,s02,s03,- s10,s11,s12,s13,- s20,s21,s22,s23,- s30,s31,s32,s33] = + applyColumns [ s0, s1, s2, s3,+ s4, s5, s6, s7,+ s8, s9,s10,s11,+ s12,s13,s14,s15] = --parMap rdeepseq g map g- [(0, (s00, s10, s20, s30)),- (0, (s01, s11, s21, s31)),- (0, (s02, s12, s22, s32)),- (0, (s03, s13, s23, s33))]+ [(0, (s0, s4, s8, s12)),+ (1, (s1, s5, s9, s13)),+ (2, (s2, s6, s10,s14)),+ (3, (s3, s7, s11,s15))] applyColumns _ = error "applyColumns: fail" @@ -518,4 +522,19 @@ in B.take 48 $ blake config salt message +++-- | Convert a digest (or other ByteString) to hexadecimal digits+-- | For example, to compute a digest of a message, "0x00", +-- using BLAKE-512 (faster on 64 bit systems),+-- with a salt of 0, and get the digits in hex:+--+-- > import Data.Digest.SHA3.Candidate.BLAKE+-- > import qualified Data.ByteString.Lazy as B+-- >+-- > textDigest $ blake512 (B.take 32 $ B.repeat 0) (B.singleton 0)+textDigest :: B.ByteString -> T.Text+textDigest digest = + T.pack $ (P.printf "%02x") =<< B.unpack digest+
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
− Setup.lhs
@@ -1,3 +0,0 @@-#!/usr/bin/env runhaskell-> import Distribution.Simple-> main = defaultMain
blakesum.cabal view
@@ -1,5 +1,5 @@ name: blakesum-version: 0.2+version: 0.3 synopsis: The BLAKE SHA-3 candidate hashes, in Haskell description: .@@ -24,7 +24,10 @@ cabal-version: >=1.6 library- build-depends: base >= 4 && < 5, vector >= 0 && < 1, bytestring >= 0 && < 1+ build-depends: base >= 4 && < 5,+ vector >= 0 && < 1,+ bytestring >= 0 && < 1,+ text >= 0 && < 1 exposed-modules: Data.Digest.SHA3.Candidate.BLAKE ghc-options: -Wall -O2