sha256

Pure Haskell SHA-256, HMAC-SHA256 as specified by RFC's 6234 and 2104.
git clone git://git.ppad.tech/sha256.git
Log | Files | Refs | README | LICENSE

commit 65c29742bbb0708f571040ba4e3d485d5958f656
parent 2a2741b8ca62d174d6d0ff39f319e00516053ef9
Author: Jared Tobin <jared@jtobin.io>
Date:   Thu, 12 Sep 2024 23:07:39 +0400

lib: same optimisation, cat

Diffstat:
Mlib/Crypto/Hash/SHA256.hs | 23+++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/lib/Crypto/Hash/SHA256.hs b/lib/Crypto/Hash/SHA256.hs @@ -316,16 +316,19 @@ hash_alg rs = block_hash rs . prepare_schedule . parse -- register concatenation cat :: Registers -> BS.ByteString -cat Registers {..} = BL.toStrict . BSB.toLazyByteString $ mconcat [ - BSB.word32BE h0 - , BSB.word32BE h1 - , BSB.word32BE h2 - , BSB.word32BE h3 - , BSB.word32BE h4 - , BSB.word32BE h5 - , BSB.word32BE h6 - , BSB.word32BE h7 - ] +cat Registers {..} = + BL.toStrict + . BE.toLazyByteStringWith (BE.safeStrategy 128 BE.smallChunkSize) mempty + $ mconcat [ + BSB.word32BE h0 + , BSB.word32BE h1 + , BSB.word32BE h2 + , BSB.word32BE h3 + , BSB.word32BE h4 + , BSB.word32BE h5 + , BSB.word32BE h6 + , BSB.word32BE h7 + ] -- | Compute a condensed representation of a strict bytestring via -- SHA-256.