Data.ByteString.Base16

base16-bytestring-0.1.1.5: Fast base16 (hex) encoding and decoding for ByteStrings

Copyright | (c) 2011 MailRank, Inc.
License | BSD
Maintainer | bos@serpentine.com
Stability | experimental
Portability | GHC
Safe Haskell | None
Language | Haskell98

Data.ByteString.Base16

Description

Fast and efficient encoding and decoding of base16-encoded strings.

Synopsis

- encode :: ByteString -> ByteString
- decode :: ByteString -> (ByteString, ByteString)

# Documentation

encode :: ByteString -> ByteString

Encode a string into base16 form. The result will always be a multiple of 2 bytes in length.

Example:

    encode "foo"  == "666f6f"

decode :: ByteString -> (ByteString, ByteString)

Decode a string from base16 form. The first element of the returned tuple contains the decoded data. The second element starts at the first invalid base16 sequence in the original string.

Examples:

    decode "666f6f"  == ("foo", "")
    decode "66quux"  == ("f", "quux")
    decode "666quux" == ("f", "6quux")