base64url -package:memory

Prism for encoding / decoding base64url. To encode, review base64url. To decode, preview base64url. Works with any combinations of strict/lazy 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.
Convert a bytestring to base64url (a variant of base64 which omits / and thus can be used in URLs):
>>> base64UrlF ("\0\50\63\80" :: BS.ByteString)
"ADI_UA=="
Tell whether a ByteString is encoded in padded or unpadded Base64url format. This function will also detect non-canonical encodings such as ZE==, which are externally valid Base64url-encoded values, but are internally inconsistent "impossible" values.

Examples:

>>> isBase64Url "PDw_Pj4="
True
>>> isBase64Url "PDw_Pj4"
True
>>> isBase64Url "PDw_Pj"
False
Tell whether a ByteString is a valid Base64url format. This will not tell you whether or not this is a correct Base64url representation, only that it conforms to the correct shape. To check whether it is a true Base64 encoded ByteString value, use isBase64Url.

Examples:

>>> isValidBase64Url "PDw_Pj4="
True
>>> isValidBase64Url "PDw_Pj"
True
>>> isValidBase64Url "%"
False
Tell whether an untyped ByteString is Base64url-encoded.

Examples:

>>> isBase64Url "PDw_Pj4="
True
>>> isBase64Url "PDw_Pj4"
True
>>> isBase64Url "PDw_Pj"
False
Tell whether an untyped ByteString is a valid Base64url format. This will not tell you whether or not this is a correct Base64url representation, only that it conforms to the correct shape. To check whether it is a true Base64 encoded ByteString value, use isBase64Url.

Examples:

>>> isValidBase64Url "PDw_Pj4="
True
>>> isValidBase64Url "PDw_Pj"
True
>>> isValidBase64Url "%"
False
Tell whether an untyped ShortByteString is Base64url-encoded.

Examples:

>>> isBase64Url "PDw_Pj4="
True
>>> isBase64Url "PDw_Pj4"
True
>>> isBase64Url "PDw_Pj"
False
Tell whether an untyped ShortByteString is a valid Base64url format. This will not tell you whether or not this is a correct Base64url representation, only that it conforms to the correct shape. To check whether it is a true Base64 encoded ShortByteString value, use isBase64Url.

Examples:

>>> isValidBase64Url "PDw_Pj4="
True
>>> isValidBase64Url "PDw_Pj"
True
>>> isValidBase64Url "%"
False
Tell whether an untyped Text value is Base64url-encoded.

Examples:

>>> isBase64Url "PDw_Pj4="
True
>>> isBase64Url "PDw_Pj4"
True
>>> isBase64Url "PDw_Pj"
False
Tell whether an untyped Text value is a valid Base64url format. This will not tell you whether or not this is a correct Base64url representation, only that it conforms to the correct shape. To check whether it is a true Base64 encoded Text value, use isBase64Url.

Examples:

>>> isValidBase64Url "PDw_Pj4="
True
>>> isValidBase64Url "PDw_Pj"
True
>>> isValidBase64Url "%"
False
Tell whether an untyped Text value is Base64url-encoded

Examples:

>>> isBase64Url "PDw_Pj4="
True
>>> isBase64Url "PDw_Pj4"
True
>>> isBase64Url "PDw_Pj"
False
Tell whether an untyped ShortText value is Base64url-encoded.

Examples:

>>> isBase64Url "PDw_Pj4="
True
>>> isBase64Url "PDw_Pj4"
True
>>> isBase64Url "PDw_Pj"
False
Tell whether an untyped ShortText value is a valid Base64url format. This will not tell you whether or not this is a correct Base64url representation, only that it conforms to the correct shape. To check whether it is a true Base64 encoded ShortText value, use isBase64Url.

Examples:

>>> isValidBase64Url "PDw_Pj4="
True
>>> isValidBase64Url "PDw_Pj"
True
>>> isValidBase64Url "%"
False
Transform string src to URL-safe base64 binary representation. The result will be either padded or unpadded, depending on the boolean padded argument.