ppad-bech32-0.1.2: The bech32 and bech32m encodings, per BIPs 173 & 350.
Copyright(c) 2024 Jared Tobin
LicenseMIT
MaintainerJared Tobin <jared@ppad.tech>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.ByteString.Bech32m

Description

The BIP350 bech32m checksummed base32 encoding, with checksum verification.

Synopsis

Encoding

encode Source #

Arguments

:: ByteString

base255-encoded human-readable part

-> ByteString

base255-encoded data part

-> Maybe ByteString

bech32m-encoded bytestring

Encode a base255 human-readable part and input as bech32m.

>>> let Just bech32m = encode "bc" "my string"
>>> bech32m
"bc1d4ujqum5wf5kuecwqlxtg"

Checksum

verify Source #

Arguments

:: ByteString

bech32m-encoded bytestring

-> Bool 

Verify that a bech32m string has a valid checksum.

>>> verify "bc1d4ujqum5wf5kuecwqlxtg"
True
>>> verify "bc1d4ujquw5wf5kuecwqlxtg" -- s/m/w
False