ppad-base16-0.2.0: Pure base16 encoding and decoding on bytestrings.
Copyright(c) 2025 Jared Tobin
LicenseMIT
MaintainerJared Tobin <jared@ppad.tech>
Safe HaskellNone
LanguageHaskell2010

Data.ByteString.Base16

Description

Pure base16 encoding and decoding of strict bytestrings.

Synopsis

Documentation

encode :: ByteString -> ByteString Source #

Encode a base256 ByteString as base16.

>>> encode "hello world"
"68656c6c6f20776f726c64"

decode :: ByteString -> Maybe ByteString Source #

Decode a base16 ByteString to base256.

Invalid inputs (including odd-length inputs) will produce Nothing.

>>> decode "68656c6c6f20776f726c64"
Just "hello world"
>>> decode "068656c6c6f20776f726c64" -- odd-length
Nothing