| Copyright | (c) 2024 Jared Tobin |
|---|---|
| License | MIT |
| Maintainer | Jared Tobin <jared@ppad.tech> |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.ByteString.Bech32m
Contents
Description
The BIP350 bech32m checksummed base32 encoding, with decoding and checksum verification.
Synopsis
- encode :: ByteString -> ByteString -> Maybe ByteString
- decode :: ByteString -> Maybe (ByteString, ByteString)
- verify :: ByteString -> Bool
Encoding and Decoding
Arguments
| :: ByteString | base256-encoded human-readable part |
| -> ByteString | base256-encoded data part |
| -> Maybe ByteString | bech32m-encoded bytestring |
Encode a base256 human-readable part and input as bech32m.
>>>let Just bech32m = encode "bc" "my string">>>bech32m"bc1d4ujqum5wf5kuecwqlxtg"
Arguments
| :: ByteString | bech23-encoded bytestring |
| -> Maybe (ByteString, ByteString) | (hrp, data less checksum) |
Decode a bech32m-encoded ByteString into its human-readable and data
parts.
>>>decode "hi1df6x7cnfdcs8wctnyp5x2un9m9ac4f"Just ("hi","jtobin was here")>>>decode "hey1df6x7cnfdcs8wctnyp5x2un9m9ac4f" -- s/hi/heyNothing
Checksum
Arguments
| :: ByteString | bech32m-encoded bytestring |
| -> Bool |
Verify that a bech32m string has a valid checksum.
>>>verify "bc1d4ujqum5wf5kuecwqlxtg"True>>>verify "bc1d4ujquw5wf5kuecwqlxtg" -- s/m/wFalse