-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Fast RFC 4648-compliant Base32 encoding -- -- RFC 4648-compliant Base32 encodings and decodings. This library -- provides performant encoding and decoding primitives, as well as -- support for textual values. @package base32 @version 0.3 -- | Internal module defining the encoding and decoding processes and -- tables. module Data.ByteString.Base32.Internal -- | Head of the padded base32 encoding loop. -- -- This function takes an alphabet in the form of an unboxed -- Addr#, allocates the correct number of bytes that will be -- written, and executes the inner encoding loop against that data. encodeBase32_ :: Addr# -> ByteString -> ByteString -- | Head of the unpadded base32 encoding loop. -- -- This function takes an alphabet in the form of an unboxed -- Addr#, allocates the correct number of bytes that will be -- written, and executes the inner encoding loop against that data. encodeBase32NoPad_ :: Addr# -> ByteString -> ByteString -- | Head of the base32 decoding loop. -- -- This function takes a base32-decoding lookup table and base32-encoded -- bytestring, allocates the correct number of bytes that will be -- written, and executes the inner decoding loop against that data. decodeBase32_ :: Ptr Word8 -> ByteString -> IO (Either Text ByteString) -- | Validate a base32-encoded bytestring against some alphabet. validateBase32 :: ByteString -> ByteString -> Bool -- | This function checks that the last N-chars of a bytestring are '=' -- and, if true, fails with a message or completes some io action. -- -- This is necessary to check when decoding permissively (i.e. filling in -- padding chars). Consider the following 8 cases of a string of length -- l: -- --
-- B32.decodeUnpadded | B32.decodePadded ~ B32.decode --validateLastNPads :: Int -> ByteString -> IO (Either Text ByteString) -> Either Text ByteString -- | This module contains ByteString-valued combinators for -- implementing the RFC 4648 specification of the Base32hex encoding -- format. This includes padded and unpadded decoding variants, as well -- as internal and external validation for canonicity. module Data.ByteString.Base32.Hex -- | Encode a ByteString value as a Base32hex Text value with -- padding. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32 "Sun" -- "ADQMS===" --encodeBase32 :: ByteString -> Text -- | Encode a ByteString value as a Base32hex ByteString -- value with padding. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32' "Sun" -- "ADQMS===" --encodeBase32' :: ByteString -> ByteString -- | Encode a ByteString value as a Base32hex Text value -- without padding. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32Unpadded' "Sun" -- "ADQMS" --encodeBase32Unpadded :: ByteString -> Text -- | Encode a ByteString value as a Base32hex ByteString -- value without padding. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32Unpadded' "Sun" -- "ADQMS" --encodeBase32Unpadded' :: ByteString -> ByteString -- | Decode an arbitrarily padded Base32hex-encoded ByteString -- value. If its length is not a multiple of 8, then padding characters -- will be added to fill out the input to a multiple of 8 for safe -- decoding, as Base32hex-encoded values are optionally padded. -- -- See: RFC-4648 section 7 -- --
-- >>> decodeBase32 "ADQMS===" -- Right "Sun" ---- --
-- >>> decodeBase32 "ADQMS" -- Right "Sun" ---- --
-- >>> decodeBase32 "ADQM===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32 :: ByteString -> Either Text ByteString -- | Decode an unpadded Base32hex-encoded ByteString value. -- -- See: RFC-4648 section 7 -- --
-- >>> decodeBase32Unpadded "ADQMS" -- Right "Sun" ---- --
-- >>> decodeBase32Unpadded "ADQMS===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32Unpadded :: ByteString -> Either Text ByteString -- | Decode a padded Base32hex-encoded ByteString value. -- -- See: RFC-4648 section 7 -- --
-- >>> decodeBase32Padded "ADQMS===" -- Right "Sun" ---- --
-- >>> decodeBase32Padded "ADQMS" -- Left "Base32-encoded bytestring requires padding" --decodeBase32Padded :: ByteString -> Either Text ByteString -- | Tell whether a ByteString value is encoded in padded or -- unpadded Base32hex format -- --
-- >>> isBase32Hex "ADQMS" -- True ---- --
-- >>> isBase32Hex "ADQMS===" -- True ---- --
-- >>> isBase32Hex "ADQMS==" -- False --isBase32Hex :: ByteString -> Bool -- | Tell whether a ByteString value is a valid Base32hex format. -- -- This will not tell you whether or not this is a correct Base32hex -- representation, only that it conforms to the correct shape (including -- padding/size etc.). To check whether it is a true Base32hex encoded -- ByteString value, use isBase32. -- --
-- >>> isValidBase32Hex "ADQMS" -- True ---- --
-- >>> isValidBase32Hex "ADQMS=" -- False ---- --
-- >>> isValidBase32Hex "ADQMS%" -- False --isValidBase32Hex :: ByteString -> Bool -- | This module contains ByteString-valued combinators for -- implementing the RFC 4648 specification of the Base32 encoding format. -- This includes padded and unpadded decoding variants, as well as -- internal and external validation for canonicity. module Data.ByteString.Base32 -- | Encode a ByteString value as a Base32 Text value with -- padding. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32 "Sun" -- "KN2W4===" --encodeBase32 :: ByteString -> Text -- | Encode a ByteString value as a Base32 ByteString value -- with padding. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32' "Sun" -- "KN2W4===" --encodeBase32' :: ByteString -> ByteString -- | Encode a ByteString value as a Base32 Text value without -- padding. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32Unpadded "Sun" -- "KN2W4" --encodeBase32Unpadded :: ByteString -> Text -- | Encode a ByteString value as a Base32 ByteString value -- without padding. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32Unpadded' "Sun" -- "KN2W4" --encodeBase32Unpadded' :: ByteString -> ByteString -- | Decode an arbitrarily padded Base32-encoded ByteString value. -- If its length is not a multiple of 8, then padding characters will be -- added to fill out the input to a multiple of 8 for safe decoding, as -- Base32-encoded values are optionally padded. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32 "KN2W4===" -- Right "Sun" ---- --
-- >>> decodeBase32 "KN2W4" -- Right "Sun" ---- --
-- >>> decodeBase32 "KN2W===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32 :: ByteString -> Either Text ByteString -- | Decode an unpadded Base32-encoded ByteString value. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32Unpadded "KN2W4" -- Right "Sun" ---- --
-- >>> decodeBase32Unpadded "KN2W4===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32Unpadded :: ByteString -> Either Text ByteString -- | Decode a padded Base32-encoded ByteString value. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32Padded "KN2W4===" -- Right "Sun" ---- --
-- >>> decodeBase32Padded "KN2W4" -- Left "Base32-encoded bytestring requires padding" --decodeBase32Padded :: ByteString -> Either Text ByteString -- | Tell whether a ByteString value is encoded in padded or -- unpadded Base32 format -- --
-- >>> isBase32 "KN2W4" -- True ---- --
-- >>> isBase32 "KN2W4===" -- True ---- --
-- >>> isBase32 "KN2W4==" -- False --isBase32 :: ByteString -> Bool -- | Tell whether a ByteString value is a valid Base32 format. -- -- This will not tell you whether or not this is a correct Base32 -- representation, only that it conforms to the correct shape (including -- padding/size etc.). To check whether it is a true Base32 encoded -- ByteString value, use isBase32. -- --
-- >>> isValidBase32 "KN2W4" -- True ---- --
-- >>> isValidBase32 "KN2W4=" -- False ---- --
-- >>> isValidBase32 "KN2W4%" -- False --isValidBase32 :: ByteString -> Bool -- | This module contains ByteString-valued combinators for -- implementing the RFC 4648 specification of the Base32 encoding format. -- This includes strictly padded/unpadded decoding variants, as well as -- internal and external validation for canonicity. module Data.ByteString.Lazy.Base32 -- | Encode a ByteString value as a Base32 Text value with -- padding. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32 "Sun" -- "KN2W4===" --encodeBase32 :: ByteString -> Text -- | Encode a ByteString as a Base32 ByteString value with -- padding. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32 "Sun" -- "KN2W4===" --encodeBase32' :: ByteString -> ByteString -- | Encode a ByteString value as Base32 Text without -- padding. Note that for Base32, padding is optional. If you call this -- function, you will simply be encoding as Base32 and stripping padding -- chars from the output. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32Unpadded "Sun" -- "KN2W4" --encodeBase32Unpadded :: ByteString -> Text -- | Encode a ByteString value as Base32 without padding. Note that -- for Base32, padding is optional. If you call this function, you will -- simply be encoding as Base32 and stripping padding chars from the -- output. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32Unpadded' "Sun" -- "KN2W4" --encodeBase32Unpadded' :: ByteString -> ByteString -- | Decode an arbitrarily padded Base32 encoded ByteString value. -- If its length is not a multiple of 4, then padding chars will be added -- to fill out the input to a multiple of 4 for safe decoding as -- Base32-encoded values are optionally padded. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32 "KN2W4===" -- Right "Sun" ---- --
-- >>> decodeBase32 "KN2W4" -- Right "Sun" ---- --
-- >>> decodeBase32 "KN2W===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32 :: ByteString -> Either Text ByteString -- | Decode an unpadded Base32-encoded ByteString value. Input -- strings are required to be unpadded, and will undergo validation prior -- to decoding to confirm. -- -- In general, unless unpadded Base32 is explicitly required, it is safer -- to call decodeBase32. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32Unpadded "KN2W4" -- Right "Sun" ---- --
-- >>> decodeBase32Unpadded "KN2W4===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32Unpadded :: ByteString -> Either Text ByteString -- | Decode a padded Base32-encoded ByteString value. Input strings -- are required to be correctly padded, and will be validated prior to -- decoding to confirm. -- -- In general, unless padded Base32 is explicitly required, it is safer -- to call decodeBase32. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32Padded "KN2W4===" -- Right "Sun" ---- --
-- >>> decodeBase32Padded "KN2W4" -- Left "Base32-encoded bytestring requires padding" --decodeBase32Padded :: ByteString -> Either Text ByteString -- | Tell whether a ByteString is Base32-encoded. -- --
-- >>> isBase32 "KN2W4" -- True ---- --
-- >>> isBase32 "KN2W4===" -- True ---- --
-- >>> isBase32 "KN2W4==" -- False --isBase32 :: ByteString -> Bool -- | Tell whether a ByteString is a valid Base32 format. -- -- This will not tell you whether or not this is a correct Base32 -- representation, only that it conforms to the correct shape. To check -- whether it is a true Base32 encoded ByteString value, use -- isBase32. -- --
-- >>> isValidBase32 "KN2W4" -- True ---- --
-- >>> isValidBase32 "KN2W4=" -- False ---- --
-- >>> isValidBase32 "KN2W4%" -- False --isValidBase32 :: ByteString -> Bool -- | This module contains ByteString-valued combinators for -- implementing the RFC 4648 specification of the Base32hex encoding -- format. This includes strictly padded/unpadded decoding variants, as -- well as internal and external validation for canonicity. module Data.ByteString.Lazy.Base32.Hex -- | Encode a ByteString value as a Base32hex Text value -- with padding. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32 "Sun" -- "ADQMS===" --encodeBase32 :: ByteString -> Text -- | Encode a ByteString as a Base32hex ByteString value with -- padding. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32' "Sun" -- "ADQMS===" --encodeBase32' :: ByteString -> ByteString -- | Encode a ByteString value as Base32hex Text without -- padding. Note that for Base32hex, padding is optional. If you call -- this function, you will simply be encoding as Base32hex and stripping -- padding chars from the output. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32Unpadded "Sun" -- "ADQMS" --encodeBase32Unpadded :: ByteString -> Text -- | Encode a ByteString value as Base32hex without padding. Note -- that for Base32hex, padding is optional. If you call this function, -- you will simply be encoding as Base32hex and stripping padding chars -- from the output. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32Unpadded' "Sun" -- "ADQMS" --encodeBase32Unpadded' :: ByteString -> ByteString -- | Decode an arbitrarily padded Base32hex encoded ByteString -- value. If its length is not a multiple of 4, then padding chars will -- be added to fill out the input to a multiple of 4 for safe decoding as -- Base32hex-encoded values are optionally padded. -- -- See: RFC-4648 section 7 -- --
-- >>> decodeBase32 "ADQMS===" -- Right "Sun" ---- --
-- >>> decodeBase32 "ADQMS" -- Right "Sun" ---- --
-- >>> decodeBase32 "ADQMS===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32 :: ByteString -> Either Text ByteString -- | Decode an unpadded Base32hex-encoded ByteString value. Input -- strings are required to be unpadded, and will undergo validation prior -- to decoding to confirm. -- -- In general, unless unpadded Base32hex is explicitly required, it is -- safer to call decodeBase32. -- -- See: RFC-4648 section 7 -- --
-- >>> decodeBase32Unpadded "ADQMS" -- Right "Sun" ---- --
-- >>> decodeBase32Unpadded "ADQMS===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32Unpadded :: ByteString -> Either Text ByteString -- | Decode a padded Base32hex-encoded ByteString value. Input -- strings are required to be correctly padded, and will be validated -- prior to decoding to confirm. -- -- In general, unless padded Base32hex is explicitly required, it is -- safer to call decodeBase32. -- -- See: RFC-4648 section 7 -- --
-- >>> decodeBase32Padded "ADQMS===" -- Right "Sun" ---- --
-- >>> decodeBase32Padded "ADQMS" -- Left "Base32-encoded bytestring requires padding" --decodeBase32Padded :: ByteString -> Either Text ByteString -- | Tell whether a ByteString is Base32hex-encoded. -- --
-- >>> isBase32Hex "ADQMS" -- True ---- --
-- >>> isBase32Hex "ADQMS===" -- True ---- --
-- >>> isBase32Hex "ADQMS==" -- False --isBase32Hex :: ByteString -> Bool -- | Tell whether a ByteString is a valid Base32hex format. -- -- This will not tell you whether or not this is a correct Base32hex -- representation, only that it conforms to the correct shape. To check -- whether it is a true Base32hex encoded ByteString value, use -- isBase32Hex. -- --
-- >>> isValidBase32Hex "ADQMS" -- True ---- --
-- >>> isValidBase32Hex "ADQMS=" -- False ---- --
-- >>> isValidBase32Hex "ADQMS%" -- False --isValidBase32Hex :: ByteString -> Bool -- | This module contains ShortByteString-valued combinators for -- implementing the RFC 4648 specification of the Base32 encoding format. -- This includes strictly padded/unpadded decoding variants, as well as -- internal and external validation for canonicity. module Data.ByteString.Short.Base32 -- | Encode a ShortByteString value as a Base32 Text value -- with padding. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32 "Sun" -- "KN2W4===" --encodeBase32 :: ShortByteString -> ShortText -- | Encode a ShortByteString as a Base32 ShortByteString -- value with padding. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32' "Sun" -- "KN2W4===" --encodeBase32' :: ShortByteString -> ShortByteString -- | Encode a ShortByteString value as Base32 Text without -- padding. Note that for Base32, padding is optional. If you call this -- function, you will simply be encoding as Base32 and stripping padding -- chars from the output. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32Unpadded "Sun" -- "KN2W4" --encodeBase32Unpadded :: ShortByteString -> ShortText -- | Encode a ShortByteString value as Base32 without padding. Note -- that for Base32, padding is optional. If you call this function, you -- will simply be encoding as Base32 and stripping padding chars from the -- output. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32Unpadded' "Sun" -- "KN2W4" --encodeBase32Unpadded' :: ShortByteString -> ShortByteString -- | Decode an arbitrarily padded Base32 encoded ShortByteString -- value. If its length is not a multiple of 4, then padding chars will -- be added to fill out the input to a multiple of 4 for safe decoding as -- Base32-encoded values are optionally padded. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32 "KN2W4===" -- Right "Sun" ---- --
-- >>> decodeBase32 "KN2W4" -- Right "Sun" ---- --
-- >>> decodeBase32 "KN2W===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32 :: ShortByteString -> Either Text ShortByteString -- | Decode an unpadded Base32-encoded ShortByteString value. Input -- strings are required to be unpadded, and will undergo validation prior -- to decoding to confirm. -- -- In general, unless unpadded Base32 is explicitly required, it is safer -- to call decodeBase32. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32Unpadded "KN2W4" -- Right "Sun" ---- --
-- >>> decodeBase32Unpadded "KN2W4===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32Unpadded :: ShortByteString -> Either Text ShortByteString -- | Decode a padded Base32-encoded ShortByteString value. Input -- strings are required to be correctly padded, and will be validated -- prior to decoding to confirm. -- -- In general, unless padded Base32 is explicitly required, it is safer -- to call decodeBase32. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32Padded "KN2W4===" -- Right "Sun" ---- --
-- >>> decodeBase32Padded "KN2W4" -- Left "Base32-encoded bytestring requires padding" --decodeBase32Padded :: ShortByteString -> Either Text ShortByteString -- | Tell whether a ShortByteString is Base32-encoded. -- --
-- >>> isBase32 "KN2W4" -- True ---- --
-- >>> isBase32 "KN2W4===" -- True ---- --
-- >>> isBase32 "KN2W4==" -- False --isBase32 :: ShortByteString -> Bool -- | Tell whether a ShortByteString is a valid Base32 format. -- -- This will not tell you whether or not this is a correct Base32 -- representation, only that it conforms to the correct shape. To check -- whether it is a true Base32 encoded ShortByteString value, use -- isBase32. -- --
-- >>> isValidBase32 "KN2W4" -- True ---- --
-- >>> isValidBase32 "KN2W4=" -- False ---- --
-- >>> isValidBase32 "KN2W4%" -- False --isValidBase32 :: ShortByteString -> Bool -- | This module contains ShortByteString-valued combinators for -- implementing the RFC 4648 specification of the Base32hex encoding -- format. This includes strictly padded/unpadded and decoding variants, -- as well as internal and external validation for canonicity. module Data.ByteString.Short.Base32.Hex -- | Encode a ShortByteString value as a Base32hex Text value -- with padding. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32 "Sun" -- "ADQMS===" --encodeBase32 :: ShortByteString -> ShortText -- | Encode a ShortByteString as a Base32hex ShortByteString -- value with padding. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32' "Sun" -- "ADQMS===" --encodeBase32' :: ShortByteString -> ShortByteString -- | Encode a ShortByteString value as Base32hex Text without -- padding. Note that for Base32hex, padding is optional. If you call -- this function, you will simply be encoding as Base32hex and stripping -- padding chars from the output. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32Unpadded' "Sun" -- "ADQMS" --encodeBase32Unpadded :: ShortByteString -> ShortText -- | Encode a ShortByteString value as Base32hex without padding. -- Note that for Base32hex, padding is optional. If you call this -- function, you will simply be encoding as Base32hex and stripping -- padding chars from the output. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32Unpadded' "Sun" -- "ADQMS" --encodeBase32Unpadded' :: ShortByteString -> ShortByteString -- | Decode an arbitrarily padded Base32hex encoded ShortByteString -- value. If its length is not a multiple of 4, then padding chars will -- be added to fill out the input to a multiple of 4 for safe decoding as -- Base32hex-encoded values are optionally padded. -- -- See: RFC-4648 section 7 -- --
-- >>> decodeBase32 "ADQMS===" -- Right "Sun" ---- --
-- >>> decodeBase32 "ADQMS" -- Right "Sun" ---- --
-- >>> decodeBase32 "ADQM===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32 :: ShortByteString -> Either Text ShortByteString -- | Decode an unpadded Base32hex-encoded ShortByteString value. -- Input strings are required to be unpadded, and will undergo validation -- prior to decoding to confirm. -- -- In general, unless unpadded Base32hex is explicitly required, it is -- safer to call decodeBase32. -- -- See: RFC-4648 section 7 -- --
-- >>> decodeBase32Unpadded "ADQMS" -- Right "Sun" ---- --
-- >>> decodeBase32Unpadded "ADQMS===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32Unpadded :: ShortByteString -> Either Text ShortByteString -- | Decode a padded Base32hex-encoded ShortByteString value. Input -- strings are required to be correctly padded, and will be validated -- prior to decoding to confirm. -- -- In general, unless padded Base32hex is explicitly required, it is -- safer to call decodeBase32. -- -- See: RFC-4648 section 7 -- --
-- >>> decodeBase32Padded "ADQMS===" -- Right "Sun" ---- --
-- >>> decodeBase32Padded "ADQMS" -- Left "Base32-encoded bytestring requires padding" --decodeBase32Padded :: ShortByteString -> Either Text ShortByteString -- | Tell whether a ShortByteString is Base32hex-encoded. -- --
-- >>> isBase32Hex "ADQMS" -- True ---- --
-- >>> isBase32Hex "ADQMS===" -- True ---- --
-- >>> isBase32Hex "ADQMS==" -- False --isBase32Hex :: ShortByteString -> Bool -- | Tell whether a ShortByteString is a valid Base32hex format. -- -- This will not tell you whether or not this is a correct Base32hex -- representation, only that it conforms to the correct shape. To check -- whether it is a true Base32 encoded ShortByteString value, use -- isBase32Hex. -- --
-- >>> isValidBase32Hex "ADQMS" -- True ---- --
-- >>> isValidBase32Hex "ADQMS=" -- False ---- --
-- >>> isValidBase32Hex "ADQMS%" -- False --isValidBase32Hex :: ShortByteString -> Bool -- | This module contains the error types raised (not as exceptions!) in -- the decoding process. module Data.Text.Encoding.Base32.Error -- | This data type represents the type of decoding errors of various kinds -- as they pertain to decoding Text values. Namely, to distinguish -- between decoding errors from opaque unicode exceptions caught in the -- unicode decoding process. data Base32Error e -- | The error associated with decoding failure as a result of the Base32 -- decoding process DecodeError :: Text -> Base32Error e -- | The error associated with the decoding failure as a result of the -- conversion process ConversionError :: e -> Base32Error e instance GHC.Generics.Generic (Data.Text.Encoding.Base32.Error.Base32Error e) instance GHC.Show.Show e => GHC.Show.Show (Data.Text.Encoding.Base32.Error.Base32Error e) instance GHC.Classes.Eq e => GHC.Classes.Eq (Data.Text.Encoding.Base32.Error.Base32Error e) instance GHC.Exception.Type.Exception e => GHC.Exception.Type.Exception (Data.Text.Encoding.Base32.Error.Base32Error e) instance Control.DeepSeq.NFData e => Control.DeepSeq.NFData (Data.Text.Encoding.Base32.Error.Base32Error e) -- | This module contains Text-valued combinators for implementing -- the RFC 4648 specification of the Base32 encoding format. This -- includes strictly padded/unpadded decoding variants, as well as -- internal and external validation for canonicity. module Data.Text.Encoding.Base32 -- | Encode a Text value in Base32 with padding. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32 "Sun" -- "KN2W4===" --encodeBase32 :: Text -> Text -- | Decode an arbitrarily padded Base32-encoded Text value. If its -- length is not a multiple of 4, then padding chars will be added to -- fill out the input to a multiple of 4 for safe decoding as base32 -- encodings are optionally padded. -- -- Note: This function makes sure that decoding is total by -- deferring to decodeLatin1. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32With and pass in a custom decode -- function. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32 "KN2W4===" -- Right "Sun" ---- --
-- >>> decodeBase32 "KN2W4" -- Right "Sun" ---- --
-- >>> decodeBase32 "KN2W===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32 :: Text -> Either Text Text -- | Attempt to decode a Text value as Base32, converting from -- ByteString to Text according to some encoding function. -- In practice, This is something like decodeUtf8', which may -- produce an error. -- -- See: RFC-4648 section 6 -- --
-- decodeBase32With decodeUtf8' -- :: ByteString -> Either (Base32Error UnicodeException) Text --decodeBase32With :: (ByteString -> Either err Text) -> ByteString -> Either (Base32Error err) Text -- | Encode a Text value in Base32 without padding. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32Unpadded "Sun" -- "KN2W4" --encodeBase32Unpadded :: Text -> Text -- | Decode an unpadded Base32 encoded Text value. -- -- Note: This function makes sure that decoding is total by -- deferring to decodeLatin1. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32WUnpaddedWith and pass in a -- custom decode function. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32Unpadded "KN2W4" -- Right "Sun" ---- --
-- >>> decodeBase32Unpadded "KN2W4===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32Unpadded :: Text -> Either Text Text -- | Attempt to decode an unpadded ByteString value as Base32, -- converting from ByteString to Text according to some -- encoding function. In practice, This is something like -- decodeUtf8', which may produce an error. -- -- See: RFC-4648 section 6 -- --
-- decodeBase32UnpaddedWith decodeUtf8' -- :: ByteString -> Either (Base32Error UnicodeException) Text --decodeBase32UnpaddedWith :: (ByteString -> Either err Text) -> ByteString -> Either (Base32Error err) Text -- | Decode an padded Base32 encoded Text value -- -- Note: This function makes sure that decoding is total by -- deferring to decodeLatin1. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32PaddedWith and pass in a custom -- decode function. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32Padded "KN2W4===" -- Right "Sun" ---- --
-- >>> decodeBase32Padded "KN2W4" -- Left "Base32-encoded bytestring requires padding" --decodeBase32Padded :: Text -> Either Text Text -- | Attempt to decode a padded ByteString value as Base32, -- converting from ByteString to Text according to some -- encoding function. In practice, This is something like -- decodeUtf8', which may produce an error. -- -- See: RFC-4648 section 6 -- --
-- decodeBase32PaddedWith decodeUtf8' -- :: ByteString -> Either (Base32Error UnicodeException) Text --decodeBase32PaddedWith :: (ByteString -> Either err Text) -> ByteString -> Either (Base32Error err) Text -- | Tell whether a Text value is Base32-encoded -- --
-- >>> isBase32 "KN2W4" -- True ---- --
-- >>> isBase32 "KN2W4===" -- True ---- --
-- >>> isBase32 "KN2W4==" -- False --isBase32 :: Text -> Bool -- | Tell whether a Text value is a valid Base32 format. -- -- This will not tell you whether or not this is a correct Base32 -- representation, only that it conforms to the correct shape. To check -- whether it is a true Base32 encoded Text value, use -- isBase32. -- --
-- >>> isValidBase32 "KN2W4" -- True ---- --
-- >>> isValidBase32 "KN2W4=" -- False ---- --
-- >>> isValidBase32 "KN2W4%" -- False --isValidBase32 :: Text -> Bool -- | This module contains Text-valued combinators for implementing -- the RFC 4648 specification of the Base32hex encoding format. This -- includes strictly padded and unpadded decoding variants, as well as -- internal and external validation for canonicity. module Data.Text.Encoding.Base32.Hex -- | Encode a Text value in Base32hex with padding. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32 "Sun" -- "ADQMS===" --encodeBase32 :: Text -> Text -- | Decode a padded Base32hex-encoded Text value. If its length is -- not a multiple of 4, then padding chars will be added to fill out the -- input to a multiple of 4 for safe decoding as base32hex encodings are -- optionally padded. -- -- Note: This function makes sure that decoding is total by -- deferring to decodeUtf8. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32With and pass in a custom decode -- function. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32 "ADQMS===" -- Right "Sun" ---- --
-- >>> decodeBase32 "ADQMS" -- Right "Sun" ---- --
-- >>> decodeBase32 "ADQMS===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32 :: Text -> Either Text Text -- | Attempt to decode a ByteString value as Base32hex, converting -- from ByteString to Text according to some encoding -- function. In practice, This is something like decodeUtf8', -- which may produce an error. -- -- See: RFC-4648 section 6 -- --
-- decodeBase32With decodeUtf8' -- :: Text -> Either (Base32Error UnicodeException) Text --decodeBase32With :: (ByteString -> Either err Text) -> ByteString -> Either (Base32Error err) Text -- | Encode a Text value in Base32hex without padding. Note that for -- Base32hex, padding is optional. If you call this function, you will -- simply be encoding as Base32hex and stripping padding chars from the -- output. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32Unpadded "Sun" -- "ADQMS" --encodeBase32Unpadded :: Text -> Text -- | Decode an unpadded Base32hex encoded Text value. -- -- Note: This function makes sure that decoding is total by -- deferring to decodeUtf8. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32WUnpaddedWith and pass in a -- custom decode function. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32Unpadded "ADQMS" -- Right "Sun" ---- --
-- >>> decodeBase32Unpadded "ADQMS===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32Unpadded :: Text -> Either Text Text -- | Attempt to decode an unpadded ByteString value as Base32hex, -- converting from ByteString to Text according to some -- encoding function. In practice, This is something like -- decodeUtf8', which may produce an error. -- -- See: RFC-4648 section 6 -- --
-- decodeBase32UnpaddedWith decodeUtf8' -- :: ByteString -> Either (Base32Error UnicodeException) Text --decodeBase32UnpaddedWith :: (ByteString -> Either err Text) -> ByteString -> Either (Base32Error err) Text -- | Decode an padded Base32hex encoded Text value -- -- Note: This function makes sure that decoding is total by -- deferring to decodeUtf8. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32PaddedWith and pass in a custom -- decode function. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32Padded "ADQMS===" -- Right "Sun" ---- --
-- >>> decodeBase32Padded "ADQMS" -- Left "Base32-encoded bytestring requires padding" --decodeBase32Padded :: Text -> Either Text Text -- | Attempt to decode a padded ByteString value as Base32hex, -- converting from ByteString to Text according to some -- encoding function. In practice, This is something like -- decodeUtf8', which may produce an error. -- -- See: RFC-4648 section 6 -- --
-- decodeBase32PaddedWith decodeUtf8' -- :: ByteString -> Either (Base32Error UnicodeException) Text --decodeBase32PaddedWith :: (ByteString -> Either err Text) -> ByteString -> Either (Base32Error err) Text -- | Tell whether a Text value is Base32hex-encoded. -- --
-- >>> isBase32Hex "ADQMS" -- True ---- --
-- >>> isBase32Hex "ADQMS===" -- True ---- --
-- >>> isBase32Hex "ADQMS==" -- False --isBase32Hex :: Text -> Bool -- | Tell whether a Text value is a valid Base32hex format. -- -- This will not tell you whether or not this is a correct Base32hex -- representation, only that it conforms to the correct shape. To check -- whether it is a true Base32 encoded Text value, use -- isBase32Hex. -- --
-- >>> isValidBase32Hex "ADQMS" -- True ---- --
-- >>> isValidBase32Hex "ADQMS=" -- False ---- --
-- >>> isValidBase32Hex "ADQMS%" -- False --isValidBase32Hex :: Text -> Bool -- | This module contains Text-valued combinators for implementing -- the RFC 4648 specification of the Base32 encoding format. This -- includes strictly padded/unpadded decoding variants, as well as -- internal and external validation for canonicity. module Data.Text.Lazy.Encoding.Base32 -- | Encode a Text value in Base32 with padding. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32 "Sun" -- "KN2W4===" --encodeBase32 :: Text -> Text -- | Encode a Text value in Base32 without padding. Note that for -- Base32, padding is optional. If you call this function, you will -- simply be encoding as Base32 and stripping padding chars from the -- output. -- -- See: RFC-4648 section 6 -- --
-- >>> encodeBase32Unpadded "Sun" -- "KN2W4" --encodeBase32Unpadded :: Text -> Text -- | Decode an arbitrarily padded Base32-encoded Text value. If its -- length is not a multiple of 4, then padding chars will be added to -- fill out the input to a multiple of 4 for safe decoding as base32 -- encodings are optionally padded. -- -- Note: This function makes sure that decoding is total by -- deferring to decodeUtf8. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32With and pass in a custom decode -- function. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32 "KN2W4===" -- Right "Sun" ---- --
-- >>> decodeBase32 "KN2W4" -- Right "Sun" ---- --
-- >>> decodeBase32 "KN2W===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32 :: Text -> Either Text Text -- | Attempt to decode a lazy ByteString value as Base32, converting -- from ByteString to Text according to some encoding -- function. In practice, This is something like decodeUtf8', -- which may produce an error. -- -- See: RFC-4648 section 6 -- --
-- decodeBase32With decodeUtf8' -- :: ByteString -> Either (Base32Error UnicodeException) Text --decodeBase32With :: (ByteString -> Either err Text) -> ByteString -> Either (Base32Error err) Text -- | Decode an unpadded Base32 encoded Text value. -- -- Note: This function makes sure that decoding is total by -- deferring to decodeUtf8. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32WUnpaddedWith and pass in a -- custom decode function. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32Unpadded "KN2W4" -- Right "Sun" ---- --
-- >>> decodeBase32Unpadded "KN2W4===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32Unpadded :: Text -> Either Text Text -- | Attempt to decode an unpadded lazy ByteString value as Base32, -- converting from ByteString to Text according to some -- encoding function. In practice, This is something like -- decodeUtf8', which may produce an error. -- -- See: RFC-4648 section 6 -- --
-- decodeBase32UnpaddedWith decodeUtf8' -- :: ByteString -> Either (Base32Error UnicodeException) Text --decodeBase32UnpaddedWith :: (ByteString -> Either err Text) -> ByteString -> Either (Base32Error err) Text -- | Decode an padded Base32 encoded Text value -- -- Note: This function makes sure that decoding is total by -- deferring to decodeUtf8. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32PaddedWith and pass in a custom -- decode function. -- -- See: RFC-4648 section 6 -- --
-- >>> decodeBase32Padded "KN2W4===" -- Right "Sun" ---- --
-- >>> decodeBase32Padded "KN2W4" -- Left "Base32-encoded bytestring requires padding" --decodeBase32Padded :: Text -> Either Text Text -- | Attempt to decode a padded lazy ByteString value as Base32, -- converting from ByteString to Text according to some -- encoding function. In practice, This is something like -- decodeUtf8', which may produce an error. -- -- See: RFC-4648 section 6 -- --
-- decodeBase32PaddedWith decodeUtf8' -- :: ByteString -> Either (Base32Error UnicodeException) Text --decodeBase32PaddedWith :: (ByteString -> Either err Text) -> ByteString -> Either (Base32Error err) Text -- | Tell whether a Text value is Base32-encoded -- --
-- >>> isBase32 "KN2W4" -- True ---- --
-- >>> isBase32 "KN2W4===" -- True ---- --
-- >>> isBase32 "KN2W4==" -- False --isBase32 :: Text -> Bool -- | Tell whether a Text value is a valid Base32 format. -- -- This will not tell you whether or not this is a correct Base32 -- representation, only that it conforms to the correct shape. To check -- whether it is a true Base32 encoded Text value, use -- isBase32. -- --
-- >>> isValidBase32 "KN2W4" -- True ---- --
-- >>> isValidBase32 "KN2W4=" -- False ---- --
-- >>> isValidBase32 "KN2W4%" -- False --isValidBase32 :: Text -> Bool -- | This module contains Text-valued combinators for implementing -- the RFC 4648 specification of the Base32hex encoding format. This -- includes strictly padded/unpadded decoding variants, as well as -- internal and external validation for canonicity. module Data.Text.Lazy.Encoding.Base32.Hex -- | Encode a Text value in Base32hex with padding. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32 "Sun" -- "ADQMS===" --encodeBase32 :: Text -> Text -- | Encode a Text value in Base32hex without padding. Note that for -- Base32hex, padding is optional. If you call this function, you will -- simply be encoding as Base32hex and stripping padding chars from the -- output. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32Unpadded "Sun" -- "ADQMS" --encodeBase32Unpadded :: Text -> Text -- | Decode a padded Base32hex-encoded Text value. If its length is -- not a multiple of 4, then padding chars will be added to fill out the -- input to a multiple of 4 for safe decoding as base32hex encodings are -- optionally padded. -- -- Note: This function makes sure that decoding is total by -- deferring to decodeUtf8. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32With and pass in a custom decode -- function. -- -- See: RFC-4648 section 7 -- --
-- >>> decodeBase32 "ADQMS===" -- Right "Sun" ---- --
-- >>> decodeBase32 "ADQMS" -- Right "Sun" ---- --
-- >>> decodeBase32 "ADQMS===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32 :: Text -> Either Text Text -- | Attempt to decode a lazy ByteString value as Base32hex, -- converting from ByteString to Text according to some -- encoding function. In practice, This is something like -- decodeUtf8', which may produce an error. -- -- See: RFC-4648 section 7 -- --
-- decodeBase32With decodeUtf8' -- :: ByteString -> Either (Base32Error UnicodeException) Text --decodeBase32With :: (ByteString -> Either err Text) -> ByteString -> Either (Base32Error err) Text -- | Decode an unpadded Base32hex encoded Text value. -- -- Note: This function makes sure that decoding is total by -- deferring to decodeUtf8. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32WUnpaddedWith and pass in a -- custom decode function. -- -- See: RFC-4648 section 7 -- --
-- >>> decodeBase32Unpadded "ADQMS" -- Right "Sun" ---- --
-- >>> decodeBase32Unpadded "ADQMS===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32Unpadded :: Text -> Either Text Text -- | Attempt to decode an unpadded lazy ByteString value as -- Base32hex, converting from ByteString to Text according -- to some encoding function. In practice, This is something like -- decodeUtf8', which may produce an error. -- -- See: RFC-4648 section 7 -- --
-- decodeBase32UnpaddedWith decodeUtf8' -- :: ByteString -> Either (Base32Error UnicodeException) Text --decodeBase32UnpaddedWith :: (ByteString -> Either err Text) -> ByteString -> Either (Base32Error err) Text -- | Decode an padded Base32hex encoded Text value -- -- Note: This function makes sure that decoding is total by -- deferring to decodeUtf8. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32PaddedWith and pass in a custom -- decode function. -- -- See: RFC-4648 section 7 -- --
-- >>> decodeBase32Padded "ADQMS===" -- Right "Sun" ---- --
-- >>> decodeBase32Padded "ADQMS" -- Left "Base32-encoded bytestring requires padding" --decodeBase32Padded :: Text -> Either Text Text -- | Attempt to decode a padded lazy ByteString value as Base32hex, -- converting from ByteString to Text according to some -- encoding function. In practice, This is something like -- decodeUtf8', which may produce an error. -- -- See: RFC-4648 section 7 -- --
-- decodeBase32PaddedWith decodeUtf8' -- :: ByteString -> Either (Base32Error UnicodeException) Text --decodeBase32PaddedWith :: (ByteString -> Either err Text) -> ByteString -> Either (Base32Error err) Text -- | Tell whether a Text value is Base32hex-encoded -- --
-- >>> isBase32Hex "ADQMS" -- True ---- --
-- >>> isBase32Hex "ADQMS===" -- True ---- --
-- >>> isBase32Hex "ADQMS==" -- False --isBase32Hex :: Text -> Bool -- | Tell whether a Text value is a valid Base32hex format. -- -- This will not tell you whether or not this is a correct Base32hex -- representation, only that it conforms to the correct shape. To check -- whether it is a true Base32 encoded Text value, use -- isBase32Hex. -- --
-- >>> isValidBase32Hex "ADQMS" -- True ---- --
-- >>> isValidBase32Hex "ADQMS=" -- False ---- --
-- >>> isValidBase32Hex "ADQMS%" -- False --isValidBase32Hex :: Text -> Bool -- | This module contains ShortText-valued combinators implementing -- the RFC 4648 specification for the Base32 encoding format. This -- includes strictly padded/unpadded decoding variants, and external + -- internal validations for canonicity. module Data.Text.Short.Encoding.Base32 -- | Encode a ShortText value in Base32 with padding. -- -- See: RFC-4328 section 6 -- --
-- >>> encodeBase32 "Sun" -- "KN2W4===" --encodeBase32 :: ShortText -> ShortText -- | Encode a ShortText value in Base32 without padding. Note that -- for Base32, padding is optional. If you call this function, you will -- simply be encoding as Base32 and stripping padding chars from the -- output. -- -- See: RFC-4328 section 6 -- --
-- >>> encodeBase32Unpadded "Sun" -- "KN2W4" --encodeBase32Unpadded :: ShortText -> ShortText -- | Decode an arbitrarily padded Base32-encoded ShortText value. If -- its length is not a multiple of 4, then padding chars will be added to -- fill out the input to a multiple of 4 for safe decoding as base32 -- encodings are optionally padded. -- -- Note: This function makes sure that decoding is total by -- deferring to decodeUtf8. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32With and pass in a custom decode -- function. -- -- See: RFC-4328 section 6 -- --
-- >>> decodeBase32 "KN2W4===" -- Right "Sun" ---- --
-- >>> decodeBase32 "KN2W4" -- Right "Sun" ---- --
-- >>> decodeBase32 "KN2W===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32 :: ShortText -> Either Text ShortText -- | Attempt to decode a ShortByteString value as Base32, converting -- from ByteString to ShortText according to some -- encoding function. In practice, This is something like -- decodeUtf8', which may produce an error. -- -- See: RFC-4328 section 6 -- --
-- decodeBase32With '(fmap fromText . T.decodeUtf8' . toText)' -- :: ShortByteString -> Either (Base32Error UnicodeException) ShortText --decodeBase32With :: (ShortByteString -> Either err ShortText) -> ShortByteString -> Either (Base32Error err) ShortText -- | Decode an unpadded Base32 encoded ShortText value. -- -- Note: This function makes sure that decoding is total by -- deferring to decodeUtf8. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32UnpaddedWith and pass in a custom -- decode function. -- -- See: RFC-4328 section 6 -- --
-- >>> decodeBase32Unpadded "KN2W4" -- Right "Sun" ---- --
-- >>> decodeBase32Unpadded "KN2W4===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32Unpadded :: ShortText -> Either Text ShortText -- | Attempt to decode an unpadded ShortByteString value as Base32, -- converting from ShortByteString to ShortText according -- to some encoding function. In practice, This is something like -- decodeUtf8', which may produce an error. -- -- See: RFC-4328 section 6 -- --
-- decodeBase32UnpaddedWith '(fmap fromText . T.decodeUtf8' . toText)' -- :: ShortByteString -> Either (Base32Error UnicodeException) ShortText --decodeBase32UnpaddedWith :: (ShortByteString -> Either err ShortText) -> ShortByteString -> Either (Base32Error err) ShortText -- | Decode an padded Base32 encoded ShortText value -- -- Note: This function makes sure that decoding is total by -- deferring to decodeUtf8. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32PaddedWith and pass in a custom -- decode function. -- -- See: RFC-4328 section 6 -- --
-- >>> decodeBase32Padded "KN2W4===" -- Right "Sun" ---- --
-- >>> decodeBase32Padded "KN2W4" -- Left "Base32-encoded bytestring requires padding" --decodeBase32Padded :: ShortText -> Either Text ShortText -- | Attempt to decode a padded ShortByteString value as Base32, -- converting from ByteString to ShortText according to -- some encoding function. In practice, This is something like -- decodeUtf8', which may produce an error. -- -- See: RFC-4328 section 6 -- --
-- decodeBase32With '(fmap fromText . T.decodeUtf8' . toText)' -- :: ShortByteString -> Either (Base32Error UnicodeException) ShortText --decodeBase32PaddedWith :: (ShortByteString -> Either err ShortText) -> ShortByteString -> Either (Base32Error err) ShortText -- | Tell whether a ShortText value is Base32-encoded. -- --
-- >>> isBase32 "KN2W4" -- True ---- --
-- >>> isBase32 "KN2W4===" -- True ---- --
-- >>> isBase32 "KN2W4==" -- False --isBase32 :: ShortText -> Bool -- | Tell whether a ShortText value is a valid Base32 format. -- -- This will not tell you whether or not this is a correct Base32 -- representation, only that it conforms to the correct shape. To check -- whether it is a true Base32 encoded ShortText value, use -- isBase32. -- --
-- >>> isValidBase32 "KN2W4" -- True ---- --
-- >>> isValidBase32 "KN2W4=" -- False ---- --
-- >>> isValidBase32 "KN2W4%" -- False --isValidBase32 :: ShortText -> Bool -- | This module contains ShortText-valued combinators implementing -- the RFC 4648 specification for the Base32hex encoding format. This -- includes strictly padded/unpadded decoding variants, and external + -- internal validations for canonicity. module Data.Text.Short.Encoding.Base32.Hex -- | Encode a ShortText value in Base32hex with padding. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32 "Sun" -- "ADQMS===" --encodeBase32 :: ShortText -> ShortText -- | Encode a ShortText value in Base32hex without padding. Note -- that for Base32hex, padding is optional. If you call this function, -- you will simply be encoding as Base32hex and stripping padding chars -- from the output. -- -- See: RFC-4648 section 7 -- --
-- >>> encodeBase32Unpadded "Sun" -- "ADQMS" --encodeBase32Unpadded :: ShortText -> ShortText -- | Decode an arbitrarily padded Base32hex-encoded ShortText value. -- If its length is not a multiple of 4, then padding chars will be added -- to fill out the input to a multiple of 4 for safe decoding as -- base32hex encodings are optionally padded. -- -- Note: This function makes sure that decoding is total by -- deferring to decodeUtf8. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32With and pass in a custom decode -- function. -- -- See: RFC-4648 section 7 -- --
-- >>> decodeBase32 "ADQMS===" -- Right "Sun" ---- --
-- >>> decodeBase32 "ADQMS" -- Right "Sun" ---- --
-- >>> decodeBase32 "ADQMS===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32 :: ShortText -> Either Text ShortText -- | Attempt to decode a ShortByteString value as Base32hex, -- converting from ByteString to ShortText according to -- some encoding function. In practice, This is something like -- decodeUtf8', which may produce an error. -- -- See: RFC-4648 section 7 -- --
-- decodeBase32With '(fmap fromText . Data.Text.Encoding.decodeUtf8' . toText)' -- :: ShortByteString -> Either (Base32Error UnicodeException) ShortText --decodeBase32With :: (ShortByteString -> Either err ShortText) -> ShortByteString -> Either (Base32Error err) ShortText -- | Decode an unpadded Base32hex encoded ShortText value. -- -- Note: This function makes sure that decoding is total by -- deferring to decodeUtf8. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32UnpaddedWith and pass in a custom -- decode function. -- -- See: RFC-4648 section 7 -- --
-- >>> decodeBase32Unpadded "ADQMS" -- Right "Sun" ---- --
-- >>> decodeBase32Unpadded "ADQMS===" -- Left "Base32-encoded bytestring has invalid padding" --decodeBase32Unpadded :: ShortText -> Either Text ShortText -- | Attempt to decode an unpadded ShortByteString value as -- Base32hex, converting from ShortByteString to ShortText -- according to some encoding function. In practice, This is something -- like decodeUtf8', which may produce an error. -- -- See: RFC-4648 section 7 -- --
-- decodeBase32UnpaddedWith '(fmap fromText . Data.Text.Encoding.decodeUtf8' . toText)' -- :: ShortByteString -> Either (Base32Error UnicodeException) ShortText --decodeBase32UnpaddedWith :: (ShortByteString -> Either err ShortText) -> ShortByteString -> Either (Base32Error err) ShortText -- | Decode an padded Base32hex encoded ShortText value -- -- Note: This function makes sure that decoding is total by -- deferring to decodeUtf8. This will always round trip for any -- valid Base32-encoded text value, but it may not round trip for bad -- inputs. The onus is on the caller to make sure inputs are valid. If -- unsure, defer to decodeBase32PaddedWith and pass in a custom -- decode function. -- -- See: RFC-4648 section 7 -- --
-- >>> decodeBase32Padded "ADQMS===" -- Right "Sun" ---- --
-- >>> decodeBase32Padded "ADQMS" -- Left "Base32-encoded bytestring requires padding" --decodeBase32Padded :: ShortText -> Either Text ShortText -- | Attempt to decode a padded ShortByteString value as Base32hex, -- converting from ByteString to ShortText according to -- some encoding function. In practice, This is something like -- decodeUtf8', which may produce an error. -- -- See: RFC-4648 section 7 -- --
-- decodeBase32With '(fmap fromText . Data.Text.Encoding.decodeUtf8' . toText)' -- :: ShortByteString -> Either (Base32Error UnicodeException) ShortText --decodeBase32PaddedWith :: (ShortByteString -> Either err ShortText) -> ShortByteString -> Either (Base32Error err) ShortText -- | Tell whether a ShortText value is Base32hex-encoded. -- --
-- >>> isBase32Hex "ADQMS" -- True ---- --
-- >>> isBase32Hex "ADQMS===" -- True ---- --
-- >>> isBase32Hex "ADQMS==" -- False --isBase32Hex :: ShortText -> Bool -- | Tell whether a ShortText value is a valid Base32hex format. -- -- This will not tell you whether or not this is a correct Base32hex -- representation, only that it conforms to the correct shape. To check -- whether it is a true Base32 encoded ShortText value, use -- isBase32Hex. -- --
-- >>> isValidBase32Hex "ADQMS" -- True ---- --
-- >>> isValidBase32Hex "ADQMS=" -- False ---- --
-- >>> isValidBase32Hex "ADQMS%" -- False --isValidBase32Hex :: ShortText -> Bool