Base64
Encode bytes with standard, URL-safe or password-hash Base64 alphabets.
from oxcrypto.encoding.base64 import BASE64
BASE64.STANDARD.encode(b"foobar") # b"Zm9vYmFy"
BASE64.URL_SAFE_UNPADDED.decode(b"-_8") # b"\xfb\xff"Decoding is strict: it rejects whitespace, line breaks, missing or extra padding, and non-zero trailing bits.
| Variant | Alphabet | Padding | Standard |
|---|---|---|---|
STANDARD | A-Z a-z 0-9 + / | Yes | RFC 4648 section 4 |
STANDARD_UNPADDED | A-Z a-z 0-9 + / | No | RFC 4648 section 4 |
URL_SAFE | A-Z a-z 0-9 - _ | Yes | RFC 4648 section 5 |
URL_SAFE_UNPADDED | A-Z a-z 0-9 - _ | No | RFC 4648 section 5 |
BCRYPT | . / A-Z a-z 0-9 | No | OpenBSD bcrypt, not standardized |
SHA_CRYPT | . / 0-9 A-Z a-z, little-endian bit order | No | SHA-crypt and other crypt(3) hashes, not standardized |
CRYPT | . / 0-9 A-Z a-z, big-endian bit order | No | Legacy, deprecated upstream |
PBKDF2 | A-Z a-z 0-9 . / | No | Passlib and PHC PBKDF2 strings, not standardized |
CRYPT is deprecated since base64ct 1.8.2 because crypt(3) hashes use the
SHA_CRYPT bit order. Use it only to read existing data that needs it.
| Crate | base64ct 1.8.3 (RustCrypto formats), stable |
| Audit | No published audit |
| MSRV | 1.85, builds with the project MSRV 1.88 |
| Experimental | No |
| Test vectors | RFC 4648 section 10, base64ct tests |