multibase-0.1.0.0: Self-identifying base encodings, implementation of <https://github.com/multiformats/multihash>

Copyright2019 Monadic GmbH
LicenseBSD3
Maintainerkim@monadic.xyz, alfredo@monadic.xyz, team@monadic.xyz
Stabilityprovisional
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell2010

Data.ByteString.Multibase

Contents

Description

multibase encoding of strict ByteStrings.

Synopsis

Supported bases

data Base (a :: Symbol) where Source #

Supported bases.

Constructors

BaseIdentity :: Base "id" 
Base2 :: Base "2" 
Base16 :: Base "16" 
Base64 :: Base "64" 
Base16upper :: Base "16u"

hexadecimal, uppercase alphabet

Base32hex :: Base "32x"

RFC4648 no padding - highest char

Base32hexupper :: Base "32xu"

RFC4648 no padding - highest char, uppercase alphabet

Base32hexpad :: Base "32xp"

RFC4648 with padding

Base32hexpadupper :: Base "32xpu"

RFC4648 with padding, uppercase alphabet

Base32 :: Base "32"

RFC4648 no padding

Base32z :: Base "32z"

z-base-32 (used by Tahoe-LAFS)

Base32upper :: Base "32u"

RFC4648 no padding, uppercase alphabet

Base32pad :: Base "32p"

RFC4648 with padding

Base32padupper :: Base "32pu"

RFC4648 with padding, uppercase alphabet

Base58flickr :: Base "58flickr"

base58 flickr alphabet

Base58btc :: Base "58btc"

base58 bitcoint alphabet

Base64pad :: Base "64p"

RFC4648 with padding (MIME-encoding)

Base64url :: Base "64url"

RFC4648 no padding

Base64urlpad :: Base "64urlp"

RFC4648 with padding

Multibase encoding and decoding

data Multibase Source #

A multibase-encoded strict ByteString.

fromMultibase :: Multibase -> ByteString Source #

Extract the encoded bytes, including the code Char, from a Multibase.

encodedBytes :: Multibase -> ByteString Source #

Extract the encoded bytes from a Multibase.

The code Char signifying the base is stripped.

encode :: ToCode b => AtBase b -> Multibase Source #

Encode a strict ByteString at Base.

decode :: ByteString -> Either String ByteString Source #

Decode a strict ByteString, assumed to be Multibase-encoded.

Compact represenation

data CompactMultibase Source #

A 'Multibase backed by a ShortByteString.

This is useful when holding many Multibase values in memory, due to lower memory overhead and less heap fragmentation. See the documentation for ShortByteString for details.

compact :: Multibase -> CompactMultibase Source #

O(n). Convert a Multibase encoding to a compact representation.

Involves copying the underlying ByteString.

expand :: CompactMultibase -> Multibase Source #

O(n). Convert from the compact to the regular representation.

Involves copying the underlying ShortByteString.