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
| API | Description |
|---|---|
| base64.encode | Encode the text stored in base64(text) into a Base64 string. |
| base64.decode | Decode the Base64 string stored in base64(text) into UTF-8 text. |
| base64.to_string | Returns the original text held in the base64 object. |
Examples
encoded = base64('BT').encode() raw = base64(encoded).decode() // Output: BT echo(raw)
mode parameter
| mode | constant | description |
|---|---|---|
0 | BASE64_STANDARD | Standard Base64 with filler. |
1 | BASE64_STANDARD_NO_PAD | Standard Base64, no complement character is output. |
2 | BASE64_URL_SAFE | URL safe Base64 with filler. |
3 | BASE64_URL_SAFE_NO_PAD | URL safe Base64, does not output filler characters. |
Notes
- Base64 is encoding, not encryption; it cannot be used to save passwords, keys, or sensitive data.