multibase-0.1.2: 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

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

class ValidBase b => ToCode b Source #

Symbols for which a multibase code is defined and supported by this library

Minimal complete definition

toCode

Instances

Instances details
ToCode "16" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "16" -> Char

ToCode "16u" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "16u" -> Char

ToCode "32" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "32" -> Char

ToCode "32p" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "32p" -> Char

ToCode "32pu" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "32pu" -> Char

ToCode "32u" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "32u" -> Char

ToCode "32x" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "32x" -> Char

ToCode "32xp" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "32xp" -> Char

ToCode "32xpu" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "32xpu" -> Char

ToCode "32xu" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "32xu" -> Char

ToCode "32z" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "32z" -> Char

ToCode "58btc" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "58btc" -> Char

ToCode "58flickr" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "58flickr" -> Char

ToCode "64" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "64" -> Char

ToCode "64p" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "64p" -> Char

ToCode "64url" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "64url" -> Char

ToCode "64urlpad" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "64urlpad" -> Char

ToCode "id" Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

toCode :: proxy "id" -> Char

Multibase encoding and decoding

data Multibase Source #

A multibase-encoded strict ByteString.

Instances

Instances details
Eq Multibase Source # 
Instance details

Defined in Data.ByteString.Multibase

Ord Multibase Source # 
Instance details

Defined in Data.ByteString.Multibase

Hashable Multibase Source # 
Instance details

Defined in Data.ByteString.Multibase

NFData Multibase Source # 
Instance details

Defined in Data.ByteString.Multibase

Methods

rnf :: Multibase -> () #

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.