-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Data encoding library -- -- Reasonably fast data encoding library. @package sandi @version 0.2.2 -- | Implementation based on the specification found at -- http://yence.sourceforge.net/docs/protocol/version1_3_draft.html. module Codec.Binary.Yenc -- | Encoding function. -- -- This function allocates enough space to hold 20% more than the size of -- the indata (or at least 512 bytes) and then encodes as much as -- possible of the indata. That means there is a risk that the encoded -- data won't fit and in that case the second part of the pair contains -- the remainder of the indata. -- --
-- >>> y_enc $ Data.ByteString.Char8.pack "foobar"
-- ("\144\153\153\140\139\156","")
--
-- >>> snd $ y_enc $ Data.ByteString.Char8.pack $ Data.List.take 257 $ repeat '\x13'
-- "\DC3"
--
y_enc :: ByteString -> (ByteString, ByteString)
-- | Decoding function.
--
--
-- >>> y_dec $ Data.ByteString.pack [144,153,153,140,139,156]
-- Right ("foobar","")
--
-- >>> y_dec $ Data.ByteString.Char8.pack "=}"
-- Right ("\DC3","")
--
--
-- A Left value is only ever returned on decoding errors which,
-- due to characteristics of the encoding, can never happen.
--
--
-- >>> y_dec $ Data.ByteString.Char8.pack "="
-- Right ("","=")
--
y_dec :: ByteString -> Either (ByteString, ByteString) (ByteString, ByteString)
-- | Convenient function that calls y_enc repeatedly until the whole
-- input data is encoded.
encode :: ByteString -> ByteString
-- | A synonym for y_dec.
decode :: ByteString -> Either (ByteString, ByteString) ByteString
module Data.Conduit.Codec.Yenc
encode :: Monad m => Conduit ByteString m ByteString
decode :: (Monad m, MonadThrow m) => Conduit ByteString m ByteString
-- | Xxencoding is obsolete but still included for completeness. Further
-- information on the encoding can be found at
-- http://en.wikipedia.org/wiki/Xxencode. It should be noted that
-- this implementation performs no padding.
--
-- This encoding is very similar to uuencoding, therefore further
-- information regarding the functions can be found in the documentation
-- of Codec.Binary.Uu.
module Codec.Binary.Xx
-- | Encoding function.
--
--
-- >>> xx_encode_part $ Data.ByteString.Char8.pack "foo"
-- ("Naxj","")
--
-- >>> xx_encode_part $ Data.ByteString.Char8.pack "foob"
-- ("Naxj","b")
--
xx_encode_part :: ByteString -> (ByteString, ByteString)
-- | Encoding function for the final block.
--
-- -- >>> xx_encode_final $ Data.ByteString.Char8.pack "r" -- Just "QU" -- -- >>> xx_encode_final $ Data.ByteString.Char8.pack "foo" -- Nothing --xx_encode_final :: ByteString -> Maybe ByteString -- | Decoding function. -- --
-- >>> xx_decode_part $ Data.ByteString.Char8.pack "Naxj"
-- Right ("foo","")
--
-- >>> xx_decode_part $ Data.ByteString.Char8.pack "NaxjMa3"
-- Right ("foo","Ma3")
--
--
--
-- >>> xx_decode_part $ Data.ByteString.Char8.pack "Na j"
-- Left ("","Na J")
--
xx_decode_part :: ByteString -> Either (ByteString, ByteString) (ByteString, ByteString)
-- | Decoding function for the final block.
--
-- -- >>> xx_decode_final $ Data.ByteString.Char8.pack "Naw" -- Just "fo" -- -- >>> xx_decode_final $ Data.ByteString.Char8.pack "" -- Just "" -- -- >>> xx_decode_final $ Data.ByteString.Char8.pack "Na " -- Nothing ---- --
-- >>> xx_decode_final $ encode $ Data.ByteString.Char8.pack "foo" -- Nothing --xx_decode_final :: ByteString -> Maybe ByteString encode :: ByteString -> ByteString decode :: ByteString -> Either (ByteString, ByteString) ByteString module Data.Conduit.Codec.Xx encode :: Monad m => Conduit ByteString m ByteString decode :: (Monad m, MonadThrow m) => Conduit ByteString m ByteString -- | Uuencoding is notoriously badly specified. This implementation aims at -- being compatible with the GNU Sharutils -- (http://www.gnu.org/software/sharutils/). -- -- Just like Base64 encoding uuencoding expands blocks of 3 bytes into -- blocks of 4 bytes. There is however no well defined ending to a piece -- of encoded data, instead uuencoded data is commonly transferred -- linewise where each line is prepended with the length of the data in -- the line. -- -- This module currently only deals with the encoding. Chopping the -- encoded data into lines, and unchopping lines into encoded data is -- left as an exercise to the reader. (Patches are welcome.) module Codec.Binary.Uu -- | Encoding function. -- -- This function encodes as large a portion of the input as possible and -- returns the encoded part together with the remaining part. Enough -- space is allocated for the encoding to make sure that the remaining -- part is less than 3 bytes long, which means it can be passed to -- uu_encode_final as is. -- --
-- >>> uu_encode_part $ Data.ByteString.Char8.pack "foo"
-- ("9F]O","")
--
-- >>> uu_encode_part $ Data.ByteString.Char8.pack "foob"
-- ("9F]O","b")
--
uu_encode_part :: ByteString -> (ByteString, ByteString)
-- | Encoding function for the final block.
--
-- The final block has to have a size less than 3.
--
-- -- >>> uu_encode_final $ Data.ByteString.Char8.pack "r" -- Just "<@" ---- -- Trying to pass in too large a block result in failure: -- --
-- >>> uu_encode_final $ Data.ByteString.Char8.pack "foo" -- Nothing --uu_encode_final :: ByteString -> Maybe ByteString -- | Decoding function. -- -- Decode as large a portion of the input as possible. Enough data is -- allocated for the output to ensure that the remainder is less than 4 -- bytes in size. Success result in a Right value: -- --
-- >>> uu_decode_part $ Data.ByteString.Char8.pack "9F]O"
-- Right ("foo","")
--
-- >>> uu_decode_part $ Data.ByteString.Char8.pack "9F]O8F$"
-- Right ("foo","8F$")
--
--
-- Failures occur on bad input and result in a Left value:
--
--
-- >>> uu_decode_part $ Data.ByteString.Char8.pack "9F 0"
-- Left ("","9F 0")
--
uu_decode_part :: ByteString -> Either (ByteString, ByteString) (ByteString, ByteString)
-- | Decoding function for the final block.
--
-- The final block has to have a size of 0 or 4:
--
-- -- >>> uu_decode_final $ Data.ByteString.Char8.pack "9F\\" -- Just "fo" -- -- >>> uu_decode_final $ Data.ByteString.Char8.pack "" -- Just "" -- -- >>> uu_decode_final $ Data.ByteString.Char8.pack "9F¬" -- Nothing ---- -- But it must be the encoding of a block that is less than 3 bytes: -- --
-- >>> uu_decode_final $ encode $ Data.ByteString.Char8.pack "foo" -- Nothing --uu_decode_final :: ByteString -> Maybe ByteString -- | Convenience function that combines uu_encode_part and -- uu_encode_final to encode a complete string. -- --
-- >>> encode $ Data.ByteString.Char8.pack "foo" -- "9F]O" -- -- >>> encode $ Data.ByteString.Char8.pack "foobar" -- "9F]O8F%R" --encode :: ByteString -> ByteString -- | Convenience function that combines uu_decode_part and -- uu_decode_final to decode a complete string. -- --
-- >>> decode $ Data.ByteString.Char8.pack "9F]O" -- Right "foo" -- -- >>> decode $ Data.ByteString.Char8.pack "9F]O8F%R" -- Right "foobar" ---- -- Failures when decoding returns the decoded part and the remainder: -- --
-- >>> decode $ Data.ByteString.Char8.pack "9F]O8F¬R"
-- Left ("foo","8F\172R")
--
decode :: ByteString -> Either (ByteString, ByteString) ByteString
module Data.Conduit.Codec.Uu
encode :: Monad m => Conduit ByteString m ByteString
decode :: (Monad m, MonadThrow m) => Conduit ByteString m ByteString
-- | Implementation of Quoted-Printable based on RFC 2045
-- (http://tools.ietf.org/html/rfc2045).
--
-- This encoding encodes everything that is passed in, it will not
-- try to guess the native line ending for your architecture. In other
-- words, if you are using this to encode text you need to split it into
-- separate lines before encoding.
module Codec.Binary.QuotedPrintable
-- | Encoding function.
--
-- This function allocates enough space to hold twice the size of the
-- indata (or at least 512 bytes) and then encodes as much as possible of
-- the indata. That means there is a risk that the encoded data won't fit
-- and in that case the second part of the pair contains the remainder of
-- the indata.
--
--
-- >>> qp_enc $ Data.ByteString.Char8.pack "="
-- ("=3D","")
--
-- >>> snd $ qp_enc $ Data.ByteString.Char8.pack $ Data.List.take 171 $ repeat '='
-- "="
--
qp_enc :: ByteString -> (ByteString, ByteString)
-- | Decoding function.
--
-- -- >>> qp_dec $ Data.ByteString.Char8.pack "foobar" -- Right "foobar" -- -- >>> qp_dec $ Data.ByteString.Char8.pack "1=20+=201=20=3D=202" -- Right "1 + 1 = 2" ---- -- The input data is allowed to use lowercase letters in the hexadecimal -- representation of an octets value, even though the standard says that -- only uppercase letters may be used: -- --
-- >>> qp_dec $ Data.ByteString.Char8.pack "=3D" -- Right "=" -- -- >>> qp_dec $ Data.ByteString.Char8.pack "=3d" -- Right "=" ---- -- It also allows the input to encode _all_ octets in the hexadecimal -- representation: -- --
-- >>> qp_dec $ Data.ByteString.Char8.pack "=20!"
-- Right (" !","")
--
-- >>> qp_dec $ Data.ByteString.Char8.pack "=20=21"
-- Right (" !","")
--
--
-- A Left value is only ever returned on decoding errors.
--
--
-- >>> qp_dec $ Data.ByteString.Char8.pack "=2"
-- Right ("","=2")
--
-- >>> qp_dec $ Data.ByteString.Char8.pack "=2g"
-- Left ("","=2g")
--
qp_dec :: ByteString -> Either (ByteString, ByteString) (ByteString, ByteString)
-- | Convenient function that calls qp_enc repeatedly until the
-- whole input data is encoded.
encode :: ByteString -> ByteString
-- | A synonym for qp_dec.
decode :: ByteString -> Either (ByteString, ByteString) ByteString
module Data.Conduit.Codec.QuotedPrintable
encode :: Monad m => Conduit ByteString m ByteString
decode :: (Monad m, MonadThrow m) => Conduit ByteString m ByteString
-- | Implemented as described at
-- http://en.wikipedia.org/wiki/Ascii85.
module Codec.Binary.Base85
-- | Encoding function.
--
-- Encodes as large a part as possible of the indata.
--
--
-- >>> b85_encode_part $ Data.ByteString.Char8.pack "foobar"
-- ("AoDTs","ar")
--
--
-- It supports special handling of both all-zero groups and all-space
-- groups.
--
--
-- >>> b85_encode_part $ Data.ByteString.Char8.pack " "
-- ("y", "")
--
-- >>> b85_encode_part $ Data.ByteString.Char8.pack "\0\0\0\0"
-- ("z", "")
--
b85_encode_part :: ByteString -> (ByteString, ByteString)
-- | Encoding function for the final block.
--
-- -- >>> b85_encode_final $ Data.ByteString.Char8.pack "ar" -- Just "@<)" --b85_encode_final :: ByteString -> Maybe ByteString -- | Decoding function. -- -- Decode as large a portion of the input as possible. -- --
-- >>> b85_decode_part $ Data.ByteString.Char8.pack "AoDTs"
-- Right ("foob","")
--
-- >>> b85_decode_part $ Data.ByteString.Char8.pack "AoDTs@<)"
-- Right ("foob","@<)")
--
-- >>> b85_decode_part $ Data.ByteString.Char8.pack "@<)"
-- Right ("","@<)")
--
--
-- At least 512 bytes of data is allocated for the output, but because of
-- the special handling of all-zero and all-space groups it is possible
-- that the space won't be enough. (To be sure to always fit the output
-- one would have to allocate 5 times the length of the input. It seemed
-- a good trade-off to sometimes have to call the function more than once
-- instead.)
--
-- -- >>> either snd snd $ b85_decode_part $ Data.ByteString.Char8.pack $ Prelude.take 129 $ repeat 'y' -- "y" --b85_decode_part :: ByteString -> Either (ByteString, ByteString) (ByteString, ByteString) -- | Decoding function for the final block. -- --
-- >>> b85_decode_final $ Data.ByteString.Char8.pack "@<)" -- Just "ar" -- -- >>> b85_decode_final $ Data.ByteString.Char8.pack "" -- Just "" -- -- >>> b85_decode_final $ Data.ByteString.Char8.pack "AoDTs" -- Nothing --b85_decode_final :: ByteString -> Maybe ByteString -- | Convenience function that combines b85_encode_part and -- b85_encode_final to encode a complete string. -- --
-- >>> encode $ Data.ByteString.Char8.pack "foob" -- "AoDTs" -- -- >>> encode $ Data.ByteString.Char8.pack "foobar" -- "AoDTs@<)" --encode :: ByteString -> ByteString -- | Convenience function that combines b85_decode_part and -- b85_decode_final to decode a complete string. -- --
-- >>> decode $ Data.ByteString.Char8.pack "AoDTs" -- "foob" -- -- >>> encode $ Data.ByteString.Char8.pack "AoDTs@<)" -- "foobar" --decode :: ByteString -> Either (ByteString, ByteString) ByteString module Data.Conduit.Codec.Base85 encode :: Monad m => Conduit ByteString m ByteString decode :: (Monad m, MonadThrow m) => Conduit ByteString m ByteString -- | Implemented as specified in RFC 4648 -- (http://tools.ietf.org/html/rfc4648). -- -- The difference compared to vanilla Base64 encoding is just in two -- characters. In Base64 the characters /+ are used, and in -- Base64Url they are replaced by _- respectively. -- -- Please refer to Codec.Binary.Base64 for the details of all -- functions in this module. module Codec.Binary.Base64Url b64u_encode_part :: ByteString -> (ByteString, ByteString) b64u_encode_final :: ByteString -> Maybe ByteString b64u_decode_part :: ByteString -> Either (ByteString, ByteString) (ByteString, ByteString) b64u_decode_final :: ByteString -> Maybe ByteString encode :: ByteString -> ByteString decode :: ByteString -> Either (ByteString, ByteString) ByteString module Data.Conduit.Codec.Base64Url encode :: Monad m => Conduit ByteString m ByteString decode :: (Monad m, MonadThrow m) => Conduit ByteString m ByteString -- | Implemented as specified in RFC 4648 -- (http://tools.ietf.org/html/rfc4648). -- -- Base64 encoding works by expanding blocks of 3 bytes of data into -- blocks of 4 bytes of data. Finally it also includes a well defined -- ending of the encoded data to make sure the size of the final block of -- encoded data is 4 bytes too. module Codec.Binary.Base64 -- | Encoding function. -- -- This function encodes as large a portion of the input as possible and -- returns the encoded part together with the remaining part. Enough -- space is allocated for the encoding to make sure that the remaining -- part is less than 3 bytes long, which means it can be passed to -- b64_encode_final as is. -- --
-- >>> b64_encode_part $ Data.ByteString.Char8.pack "foo"
-- ("Zm9v","")
--
-- >>> b64_encode_part $ Data.ByteString.Char8.pack "foob"
-- ("Zm9v","b")
--
b64_encode_part :: ByteString -> (ByteString, ByteString)
-- | Encoding function for the final block.
--
-- The final block has to have a size less than 3.
--
-- -- >>> b64_encode_final $ Data.ByteString.Char8.pack "r" -- Just "cg==" ---- -- Trying to pass in too large a block result in failure: -- --
-- >>> b64_encode_final $ Data.ByteString.Char8.pack "foo" -- Nothing --b64_encode_final :: ByteString -> Maybe ByteString -- | Decoding function. -- -- Decode as large a portion of the input as possible. Enough data is -- allocated for the output to ensure that the remainder is less than 4 -- bytes in size. Success result in a Right value: -- --
-- >>> b64_decode_part $ Data.ByteString.Char8.pack "Zm9v"
-- Right ("foo","")
--
-- >>> b64_decode_part $ Data.ByteString.Char8.pack "Zm9vYmE="
-- Right ("foo","YmE=")
--
--
-- Failures occur on bad input and result in a Left value:
--
--
-- >>> b64_decode_part $ Data.ByteString.Char8.pack "Z=9v"
-- Left ("","Z=9v")
--
b64_decode_part :: ByteString -> Either (ByteString, ByteString) (ByteString, ByteString)
-- | Decoding function for the final block.
--
-- The final block has to have a size of 0 or 4:
--
-- -- >>> b64_decode_final $ Data.ByteString.Char8.pack "Zm8=" -- Just "fo" -- -- >>> b64_decode_final $ Data.ByteString.Char8.pack "" -- Just "" -- -- >>> b64_decode_final $ Data.ByteString.Char8.pack "Zm=" -- Nothing ---- -- But it must be the encoding of a block that is less than 3 bytes: -- --
-- >>> b64_decode_final $ encode $ Data.ByteString.Char8.pack "foo" -- Nothing --b64_decode_final :: ByteString -> Maybe ByteString -- | Convenience function that combines b64_encode_part and -- b64_encode_final to encode a complete string. -- --
-- >>> encode $ Data.ByteString.Char8.pack "foo" -- "Zm9v" -- -- >>> encode $ Data.ByteString.Char8.pack "foobar" -- "Zm9vYmFy" --encode :: ByteString -> ByteString -- | Convenience function that combines b64_decode_part and -- b64_decode_final to decode a complete string. -- --
-- >>> decode $ Data.ByteString.Char8.pack "Zm9v" -- Right "foo" -- -- >>> decode $ Data.ByteString.Char8.pack "Zm9vYmFy" -- Right "foobar" ---- -- Failures when decoding returns the decoded part and the remainder: -- --
-- >>> decode $ Data.ByteString.Char8.pack "Zm9vYm=y"
-- Left ("foo","Ym=y")
--
decode :: ByteString -> Either (ByteString, ByteString) ByteString
module Data.Conduit.Codec.Base64
encode :: Monad m => Conduit ByteString m ByteString
decode :: (Monad m, MonadThrow m) => Conduit ByteString m ByteString
-- | Implemented as specified in RFC 4648
-- (http://tools.ietf.org/html/rfc4648).
--
-- This encoding is closely related to base 32 and so is its
-- implementation, so please refer to Codec.Binary.Base32 for
-- further details.
module Codec.Binary.Base32Hex
-- | Encoding function.
--
-- See b32_encode_part.
--
--
-- >>> b32h_encode_part $ Data.ByteString.Char8.pack "fooba"
-- ("CPNMUOJ1","")
--
-- >>> b32h_encode_part $ Data.ByteString.Char8.pack "foobar"
-- ("CPNMUOJ1","r")
--
b32h_encode_part :: ByteString -> (ByteString, ByteString)
-- | Encoding function for the final block.
--
-- See b32_encode_final.
--
-- -- >>> b32h_encode_final $ Data.ByteString.Char8.pack "r" -- Just "E8======" -- -- >>> b32h_encode_final $ Data.ByteString.Char8.pack "fooba" -- Nothing --b32h_encode_final :: ByteString -> Maybe ByteString -- | Decoding function. -- -- See b32_decode_part. -- --
-- >>> b32h_decode_part $ Data.ByteString.Char8.pack "CPNMUOJ1"
-- Right ("fooba","")
--
-- >>> b32h_decode_part $ Data.ByteString.Char8.pack "CPNMUOJ1E8======"
-- Right ("fooba","E8======")
--
-- >>> b32h_decode_part $ Data.ByteString.Char8.pack "C=NMUOJ1"
-- Left ("","C=NMUOJ1")
--
b32h_decode_part :: ByteString -> Either (ByteString, ByteString) (ByteString, ByteString)
-- | Decoding function for the final block.
--
-- See b32_decode_final.
--
-- -- >>> b32h_decode_final $ Data.ByteString.Char8.pack "CPNMUOG=" -- Just "foob" -- -- >>> b32h_decode_final $ Data.ByteString.Char8.pack "" -- Just "" -- -- >>> b32h_decode_final $ Data.ByteString.Char8.pack "CPNMUO=" -- Nothing -- -- >>> b32h_decode_final $ encode $ Data.ByteString.Char8.pack "fooba" -- Nothing --b32h_decode_final :: ByteString -> Maybe ByteString -- | Convenience function that combines b32h_encode_part and -- b32h_encode_final to encode a complete string. -- --
-- >>> encode $ Data.ByteString.Char8.pack "fooba" -- "CPNMUOJ1" -- -- >>> encode $ Data.ByteString.Char8.pack "foobar" -- "CPNMUOJ1E8======" --encode :: ByteString -> ByteString -- | Convenience function that combines b32h_decode_part and -- b32h_decode_final to decode a complete string. -- --
-- >>> decode $ Data.ByteString.Char8.pack "CPNMUOJ1" -- Right "fooba" -- -- >>> decode $ Data.ByteString.Char8.pack "CPNMUOJ1E8======" -- Right "foobar" ---- -- Failures when decoding returns the decoded part and the remainder: -- --
-- >>> decode $ Data.ByteString.Char8.pack "CPNMUOJ1=8======"
-- Left ("fooba","=8======")
--
decode :: ByteString -> Either (ByteString, ByteString) ByteString
module Data.Conduit.Codec.Base32Hex
encode :: Monad m => Conduit ByteString m ByteString
decode :: (Monad m, MonadThrow m) => Conduit ByteString m ByteString
-- | Implemented as specified in RFC 4648
-- (http://tools.ietf.org/html/rfc4648).
--
-- Base32 encoding works by expanding blocks of 5 bytes of data into
-- blocks of 8 bytes of data. Finally it also includes a well defined
-- ending of the encoded data to make sure the size of the final block of
-- encoded data is 8 bytes too.
module Codec.Binary.Base32
-- | Encoding function.
--
-- This function encodes as large a portion of the input as possible and
-- returns the encoded part together with the remaining part. Enough
-- space is allocated for the encoding to make sure that the remaining
-- part is less than 5 bytes long, which means it can be passed to
-- b32_encode_final as is.
--
--
-- >>> b32_encode_part $ Data.ByteString.Char8.pack "fooba"
-- ("MZXW6YTB","")
--
-- >>> b32_encode_part $ Data.ByteString.Char8.pack "foobar"
-- ("MZXW6YTB","r")
--
b32_encode_part :: ByteString -> (ByteString, ByteString)
-- | Encoding function for the final block.
--
-- The final block has to have a size less than 5.
--
-- -- >>> b32_encode_final $ Data.ByteString.Char8.pack "r" -- Just "OI======" ---- -- Trying to pass in too large a block result in failure: -- --
-- >>> b32_encode_final $ Data.ByteString.Char8.pack "fooba" -- Nothing --b32_encode_final :: ByteString -> Maybe ByteString -- | Decoding function. -- -- Decode as large a portion of the input as possible. Enough data is -- allocated for the output to ensure that the remainder is less than 8 -- bytes in size. Success result in a Right value: -- --
-- >>> b32_decode_part $ Data.ByteString.Char8.pack "MZXW6YTB"
-- Right ("fooba","")
--
-- >>> b32_decode_part $ Data.ByteString.Char8.pack "MZXW6YTBOI======"
-- Right ("fooba","OI======")
--
--
-- Failures occur on bad input and result in a Left value:
--
--
-- >>> b32_decode_part $ Data.ByteString.Char8.pack "M=XW6YTB"
-- Left ("","M=XW6YTB")
--
b32_decode_part :: ByteString -> Either (ByteString, ByteString) (ByteString, ByteString)
-- | Decoding function for the final block.
--
-- The final block has to have a size of 0 or 8:
--
-- -- >>> b32_decode_final $ Data.ByteString.Char8.pack "MZXW6YQ=" -- Just "foob" -- -- >>> b32_decode_final $ Data.ByteString.Char8.pack "" -- Just "" -- -- >>> b32_decode_final $ Data.ByteString.Char8.pack "MZXW6Y=" -- Nothing ---- -- But it must be the encoding of a block that is less than 5 bytes: -- --
-- >>> b32_decode_final $ encode $ Data.ByteString.Char8.pack "fooba" -- Nothing --b32_decode_final :: ByteString -> Maybe ByteString -- | Convenience function that combines b32_encode_part and -- b32_encode_final to encode a complete string. -- --
-- >>> encode $ Data.ByteString.Char8.pack "fooba" -- "MZXW6YTB" -- -- >>> encode $ Data.ByteString.Char8.pack "foobar" -- "MZXW6YTBOI======" --encode :: ByteString -> ByteString -- | Convenience function that combines b32_decode_part and -- b32_decode_final to decode a complete string. -- --
-- >>> decode $ Data.ByteString.Char8.pack "MZXW6YTB" -- Right "fooba" -- -- >>> decode $ Data.ByteString.Char8.pack "MZXW6YTBOI======" -- Right "foobar" ---- -- Failures when decoding returns the decoded part and the remainder: -- --
-- >>> decode $ Data.ByteString.Char8.pack "MZXW6YTBOI=0===="
-- Left ("fooba","OI=0====")
--
decode :: ByteString -> Either (ByteString, ByteString) ByteString
module Data.Conduit.Codec.Base32
encode :: Monad m => Conduit ByteString m ByteString
decode :: (Monad m, MonadThrow m) => Conduit ByteString m ByteString
-- | Implemention of base 16 encoding (hex encoding) as specified in RFC
-- 4648 (http://tools.ietf.org/html/rfc4648).
module Codec.Binary.Base16
-- | Encoding function.
--
-- This function, unlike some other encoding functions in the library,
-- simply cannot fail. Double the length of the input string is allocated
-- for the encoded data, which is guaranteed to hold the result.
--
-- -- >>> b16_enc $ Data.ByteString.pack [0x00] -- "00" ---- --
-- >>> b16_enc $ Data.ByteString.Char8.pack "foobar" -- "666F6F626172" --b16_enc :: ByteString -> ByteString -- | Decoding function. -- -- The returned value on success is Right (<decoded part>, -- <undecoded part>) (the undecoded part is either a empty or -- a single byte), and on failure it's Left (<decoded part>, -- <undecodable part>). Space equal to the length of the input -- string is allocated, which is more than enough to hold the decoded -- data. -- --
-- >>> b16_dec $ Data.ByteString.Char8.pack "00"
-- Right ("\NUL","")
--
--
--
-- >>> b16_dec $ Data.ByteString.Char8.pack "666F6F626172"
-- Right ("foobar","")
--
--
--
-- >>> b16_dec $ Data.ByteString.Char8.pack "666F6F62617"
-- Right ("fooba","7")
--
-- >>> b16_dec $ Data.ByteString.Char8.pack "666F6F62617g"
-- Left ("fooba","g")
--
b16_dec :: ByteString -> Either (ByteString, ByteString) (ByteString, ByteString)
-- | A synonym for b16_enc.
encode :: ByteString -> ByteString
-- | A synonum for b16_dec.
decode :: ByteString -> Either (ByteString, ByteString) ByteString
module Data.Conduit.Codec.Base16
encode :: Monad m => Conduit ByteString m ByteString
decode :: (Monad m, MonadThrow m) => Conduit ByteString m ByteString