Module
Data.Binary.Base64
- Package
- purescript-b64
- Repository
- menelaos/purescript-b64
#decode Source
decode :: String -> Either Error Uint8ArrayDecode a Base64-encoded String.
This function handles both normal (RFC 4648) and URL-safe input strings.
Returns an Error for invalid input strings.
Example:
decode "5p+/44GP44G444Gw6ZCY44GM6bO044KL44Gq44KK5rOV6ZqG5a+6"
>>= decodeUtf8
-- Right "柿くへば鐘が鳴るなり法隆寺"
decode "5p-_44GP44G444Gw6ZCY44GM6bO044KL44Gq44KK5rOV6ZqG5a-6"
>>= decodeUtf8
-- Right "柿くへば鐘が鳴るなり法隆寺"
decode "∀"
-- ✗ Invalid input string
#encode Source
encode :: Uint8Array -> StringEncode a Uint8Array to its (RFC 4648) Base64 representation.
Example:
encode $ encodeUtf8 "柿くへば鐘が鳴るなり法隆寺"
-- "5p+/44GP44G444Gw6ZCY44GM6bO044KL44Gq44KK5rOV6ZqG5a+6"
#encodeUrl Source
encodeUrl :: Uint8Array -> StringEncode a Uint8Array to a URL-safe Base64 representation.
Example:
encodeUrl $ encodeUtf8 "柿くへば鐘が鳴るなり法隆寺"
-- "5p-_44GP44G444Gw6ZCY44GM6bO044KL44Gq44KK5rOV6ZqG5a-6"