bech32

Fast Haskell bech32, bech32m encoding/decoding (docs.ppad.tech/bech32).
git clone git://git.ppad.tech/bech32.git
Log | Files | Refs | README | LICENSE

commit eee8c7a53ce709b62f86654c53677e47c66e1249
parent 7b6bfc359adb5f1b9eda4301ab835af41b0b2fe7
Author: Jared Tobin <jared@jtobin.io>
Date:   Sat, 10 Oct 2026 15:22:16 +0400

lib: mask as_base32 input to five bits

Diffstat:
Mlib/Data/ByteString/Bech32/Internal.hs | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/Data/ByteString/Bech32/Internal.hs b/lib/Data/ByteString/Bech32/Internal.hs @@ -54,7 +54,7 @@ as_word5 (BI.PS sfp soff l) = case dec_tab of pure $! if ok then Just (BI.PS fp 0 l) else Nothing -- | Translate a 5-bit-value bytestring to its bech32 base32 --- bytestring. +-- bytestring. Only the low 5 bits of each input byte are used. as_base32 :: BS.ByteString -> BS.ByteString as_base32 (BI.PS sfp soff l) = case enc_tab of BI.PS tfp toff _ -> @@ -67,7 +67,7 @@ as_base32 (BI.PS sfp soff l) = case enc_tab of | i == l = pure () | otherwise = do v <- peekElemOff sp i - c <- peekElemOff tp (fi v) + c <- peekElemOff tp (fi (v .&. 0x1f)) pokeElemOff dst i c loop (i + 1) loop 0