From 75111610a64fdc06504641469df2192584435dbb Mon Sep 17 00:00:00 2001 From: Bob Harris Date: Mon, 22 Jul 2019 12:01:38 -0400 Subject: [PATCH] (had more trouble with push) set fields so that callers can inspect the state of the hasher --- sabuhash.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/sabuhash.h b/sabuhash.h index 01b07e1..496ecdc 100644 --- a/sabuhash.h +++ b/sabuhash.h @@ -204,6 +204,8 @@ class SabuHash hF = forward(hF) ^ kernelTable[chIn]; } + hForward = hF; + hF = avalanche(hF); if (hF == 0) return 1; else return hF; @@ -224,6 +226,8 @@ class SabuHash hF = forward(hF) ^ kernelTable[chIn]; } + hForward = hF; + hF = avalanche(hF); if (hF == 0) return 1; else return hF; @@ -246,6 +250,8 @@ class SabuHash hF = backward(hF ^ forwardByK2[twoBits]); } + hForward = hF; + hF = avalanche(hF); if (hF == 0) return 1; else return hF; @@ -253,7 +259,7 @@ class SabuHash inline std::uint64_t rolling_hash (const unsigned char chIn, - const unsigned char chOut=0) + const unsigned char chOut=0) // this was chIn k characters earlier { // note that we return 0 iff we don't yet have k characters @@ -493,6 +499,9 @@ class SabuHashCanonical hR = SabuHash::backward(hR ^ forwardByK_RC[chIn]); } + hForward = hF; + hRevComp = hR; + std::uint64_t h = SabuHash::avalanche(hF+hR); if (h == 0) return 1; else return h; @@ -515,6 +524,9 @@ class SabuHashCanonical hR = SabuHash::backward(hR ^ forwardByK_RC[chIn]); } + hForward = hF; + hRevComp = hR; + std::uint64_t h = SabuHash::avalanche(hF+hR); if (h == 0) return 1; else return h; @@ -537,6 +549,9 @@ class SabuHashCanonical hR = SabuHash::forward(hR) ^ kernelTable2_RC[twoBits]; } + hForward = hF; + hRevComp = hR; + std::uint64_t h = SabuHash::avalanche(hF+hR); if (h == 0) return 1; else return h; @@ -544,7 +559,7 @@ class SabuHashCanonical inline std::uint64_t rolling_hash (const unsigned char chIn, - const unsigned char chOut=0) + const unsigned char chOut=0) // this was chIn k characters earlier { // note that we return 0 iff we don't yet have k characters