ppad-base58-0.1.0: base58 and base58check encoding/decoding.
Copyright(c) 2024 Jared Tobin
LicenseMIT
MaintainerJared Tobin <jared@ppad.tech>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.ByteString.Base58Check

Description

base58check encoding and decoding of strict bytestrings.

base58check is a versioned, checksummed base58 encoding. A payload is constructed from a leading version byte and some base256 input, and then a checksum is computed by SHA256d-ing the payload, appending its first 4 bytes, and base58-encoding the result.

Synopsis

Documentation

encode :: Word8 -> ByteString -> ByteString Source #

Encode a version byte and base256 ByteString as base58check.

>>> encode 0x00 "hello world"
"13vQB7B6MrGQZaxCqW9KER"

decode :: ByteString -> Maybe (Word8, ByteString) Source #

Validate and decode a base58check-encoded string. Invalid base58check inputs will produce Nothing.

>>> decode "13vQB7B6MrGQZaxCqW9KER"
Just (0,"hello world")
>>> decode "13uQB7B6MrGQZaxCqW9KER" -- s/v/u
Nothing