base64 codec library

base64 codec library

base64 codec library

Function

base64(text) creates a lightweight codec object, supporting standard Base64, non-padded Base64, URL-safe Base64 and URL-safe non-padded Base64.

API list

APIDescription
base64.encodeEncode the text stored in base64(text) into a Base64 string.
base64.decodeDecode the Base64 string stored in base64(text) into UTF-8 text.
base64.to_stringReturns the original text held in the base64 object.

Examples

mode parameter

modeconstantdescription
0BASE64_STANDARDStandard Base64 with filler.
1BASE64_STANDARD_NO_PADStandard Base64, no complement character is output.
2BASE64_URL_SAFEURL safe Base64 with filler.
3BASE64_URL_SAFE_NO_PADURL safe Base64, does not output filler characters.

Notes

  • Base64 is encoding, not encryption; it cannot be used to save passwords, keys, or sensitive data.