Weird bit fiddling to make printHashBytes32 work

This commit is contained in:
John Ericson 2019-03-09 22:03:28 -05:00
parent 440dfebc28
commit 0fe7ff5e84

View File

@ -126,7 +126,7 @@ printHashBytes32 :: BS.ByteString -> T.Text
printHashBytes32 c = T.pack $ concatMap char32 [nChar - 1, nChar - 2 .. 0]
where
-- The base32 encoding is 8/5's as long as the base256 digest
nChar = fromIntegral $ BS.length c * 8 `div` 5
nChar = fromIntegral $ ((BS.length c * 8 - 1) `div` 5) + 1
char32 :: Integer -> [Char]
char32 i = [digits32 V.! digitInd]