Skip to Content
oxcrypto

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.

VariantAlphabetPaddingStandard
STANDARDA-Z a-z 0-9 + /YesRFC 4648 section 4
STANDARD_UNPADDEDA-Z a-z 0-9 + /NoRFC 4648 section 4
URL_SAFEA-Z a-z 0-9 - _YesRFC 4648 section 5
URL_SAFE_UNPADDEDA-Z a-z 0-9 - _NoRFC 4648 section 5
BCRYPT. / A-Z a-z 0-9NoOpenBSD bcrypt, not standardized
SHA_CRYPT. / 0-9 A-Z a-z, little-endian bit orderNoSHA-crypt and other crypt(3) hashes, not standardized
CRYPT. / 0-9 A-Z a-z, big-endian bit orderNoLegacy, deprecated upstream
PBKDF2A-Z a-z 0-9 . /NoPasslib 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.

Cratebase64ct 1.8.3 (RustCrypto formats), stable
AuditNo published audit
MSRV1.85, builds with the project MSRV 1.88
ExperimentalNo
Test vectorsRFC 4648 section 10, base64ct tests