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.Bech32

Description

The BIP0173 bech32 checksummed base32 encoding, with checksum verification.

Synopsis

Encoding

encode Source #

Arguments

:: ByteString

base255-encoded human-readable part

-> ByteString

base255-encoded data part

-> Maybe ByteString

bech32-encoded bytestring

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

>>> let Just bech32 = encode "bc" "my string"
>>> bech32
"bc1d4ujqum5wf5kuecmu02w2"

Checksum

verify Source #

Arguments

:: ByteString

bech32-encoded bytestring

-> Bool 

Verify that a bech32 string has a valid checksum.

>>> verify "bc1d4ujqum5wf5kuecmu02w2"
True
>>> verify "bc1d4ujquw5wf5kuecmu02w2" -- s/m/w
False