| Copyright | (c) 2012 Magnus Therning |
|---|---|
| License | BSD3 |
| Safe Haskell | None |
| Language | Haskell2010 |
Codec.Binary.Base32Hex
Description
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.
Synopsis
- b32hEncodePart :: ByteString -> (ByteString, ByteString)
- b32hEncodeFinal :: ByteString -> Maybe ByteString
- b32hDecodePart :: ByteString -> Either (ByteString, ByteString) (ByteString, ByteString)
- b32hDecodeFinal :: ByteString -> Maybe ByteString
- encode :: ByteString -> ByteString
- decode :: ByteString -> Either (ByteString, ByteString) ByteString
Documentation
b32hEncodePart :: ByteString -> (ByteString, ByteString) #
Encoding function.
See b32_encode_part.
>>>b32hEncodePart $ Data.ByteString.Char8.pack "fooba"("CPNMUOJ1","")>>>b32hEncodePart $ Data.ByteString.Char8.pack "foobar"("CPNMUOJ1","r")
b32hEncodeFinal :: ByteString -> Maybe ByteString #
Encoding function for the final block.
See b32_encode_final.
>>>b32hEncodeFinal $ Data.ByteString.Char8.pack "r"Just "E8======">>>b32hEncodeFinal $ Data.ByteString.Char8.pack "fooba"Nothing
b32hDecodePart :: ByteString -> Either (ByteString, ByteString) (ByteString, ByteString) #
Decoding function.
See b32_decode_part.
>>>b32hDecodePart $ Data.ByteString.Char8.pack "CPNMUOJ1"Right ("fooba","")>>>b32hDecodePart $ Data.ByteString.Char8.pack "CPNMUOJ1E8======"Right ("fooba","E8======")>>>b32hDecodePart $ Data.ByteString.Char8.pack "C=NMUOJ1"Left ("","C=NMUOJ1")
b32hDecodeFinal :: ByteString -> Maybe ByteString #
Decoding function for the final block.
See b32_decode_final.
>>>b32hDecodeFinal $ Data.ByteString.Char8.pack "CPNMUOG="Just "foob">>>b32hDecodeFinal $ Data.ByteString.Char8.pack ""Just "">>>b32hDecodeFinal $ Data.ByteString.Char8.pack "CPNMUO="Nothing>>>b32hDecodeFinal $ encode $ Data.ByteString.Char8.pack "fooba"Nothing
encode :: ByteString -> 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======"
decode :: ByteString -> Either (ByteString, 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======")