Skip to content

Commit ecf4d99

Browse files
committed
Add comment to the mysterious order of the + 1 - 1 in printHashBytes32
1 parent 9bbe54a commit ecf4d99

File tree

1 file changed

+4
-1
lines changed
  • hnix-store-core/src/System/Nix/Internal

1 file changed

+4
-1
lines changed

hnix-store-core/src/System/Nix/Internal/Hash.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ newtype Digest (a :: HashAlgorithm) = Digest
125125
printHashBytes32 :: BS.ByteString -> T.Text
126126
printHashBytes32 c = T.pack $ concatMap char32 [nChar - 1, nChar - 2 .. 0]
127127
where
128-
-- The base32 encoding is 8/5's as long as the base256 digest
128+
-- The base32 encoding is 8/5's as long as the base256 digest. This `+ 1`
129+
-- `- 1` business is a bit odd, but has always been used in C++ since the
130+
-- base32 truncation was added in was first added in
131+
-- d58a11e019813902b6c4547ca61a127938b2cc20.
129132
nChar = fromIntegral $ ((BS.length c * 8 - 1) `div` 5) + 1
130133

131134
char32 :: Integer -> [Char]

0 commit comments

Comments
 (0)