Data.Memory.Encoding.Base64

memory-0.11: memory and related abstraction stuff

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | unknown
Safe Haskell | None
Language | Haskell2010

Data.Memory.Encoding.Base64

Description

Base64

Synopsis

- toBase64 :: Ptr Word8 -> Ptr Word8 -> Int -> IO ()
- toBase64URL :: Bool -> Ptr Word8 -> Ptr Word8 -> Int -> IO ()
- toBase64OpenBSD :: Ptr Word8 -> Ptr Word8 -> Int -> IO ()
- unBase64Length :: Ptr Word8 -> Int -> IO (Maybe Int)
- unBase64LengthUnpadded :: Int -> Maybe Int
- fromBase64 :: Ptr Word8 -> Ptr Word8 -> Int -> IO (Maybe Int)
- fromBase64URLUnpadded :: Ptr Word8 -> Ptr Word8 -> Int -> IO (Maybe Int)
- fromBase64OpenBSD :: Ptr Word8 -> Ptr Word8 -> Int -> IO (Maybe Int)

# Documentation

toBase64 :: Ptr Word8 -> Ptr Word8 -> Int -> IO ()

Transform a number of bytes pointed by `src` to base64 binary representation in `dst`

The destination memory need to be of correct size, otherwise it will lead to really bad things.

toBase64URL :: Bool -> Ptr Word8 -> Ptr Word8 -> Int -> IO ()

Transform a number of bytes pointed by `src` to, URL-safe base64 binary representation in `dst`. The result will be either padded or unpadded, depending on the boolean `padded` argument.

The destination memory need to be of correct size, otherwise it will lead to really bad things.

toBase64OpenBSD :: Ptr Word8 -> Ptr Word8 -> Int -> IO ()

unBase64Length :: Ptr Word8 -> Int -> IO (Maybe Int)

Get the length needed for the destination buffer for a base64 decoding.

if the length is not a multiple of 4, Nothing is returned

unBase64LengthUnpadded :: Int -> Maybe Int

Get the length needed for the destination buffer for an unpadded base64 decoding.

If the length of the encoded string is a multiple of 4, plus one, Nothing is returned. Any other value can be valid without padding.

fromBase64 :: Ptr Word8 -> Ptr Word8 -> Int -> IO (Maybe Int)

convert from base64 in `src` to binary in `dst`, using the number of bytes specified

the user should use unBase64Length to compute the correct length, or check that the length specification is proper. no check is done here.

fromBase64URLUnpadded :: Ptr Word8 -> Ptr Word8 -> Int -> IO (Maybe Int)

fromBase64OpenBSD :: Ptr Word8 -> Ptr Word8 -> Int -> IO (Maybe Int)