hbutils.encoding.base64¶
- Overview:
Base64 encode and decode.
base64_encode¶
-
hbutils.encoding.base64.
base64_encode
(data: bytes, altchars: Optional[bytes] = None, urlsafe: bool = False) → str[source]¶ - Overview:
Encoding the given binary
data
to base64 string.- Arguments:
data (
bytes
): Binary data to be encoded.altchars (
Optional[bytes]
): Characters to be altered, default isNone
.urlsafe (
bool
): Enable urlsafe mode, default isFalse
.
Examples:
>>> base64_encode(b'jvMIQ?K;]kNn2?1KD5H>') anZNSVE/Sztda05uMj8xS0Q1SD4= >>> base64_encode(b'jvMIQ?K;]kNn2?1KD5H>', urlsafe=True) anZNSVE_Sztda05uMj8xS0Q1SD4=
base64_decode¶
-
hbutils.encoding.base64.
base64_decode
(base64_str: str, altchars: Optional[bytes] = None, urlsafe: bool = False) → bytes[source]¶ - Overview:
Decode the given base64 string
base64_str
back to binary data.- Arguments:
base64_str (
str
): Base64 string to be decoded.altchars (
Optional[bytes]
): Characters to be altered, default isNone
.urlsafe (
bool
): Enable urlsafe mode, default isFalse
.
Examples:
>>> base64_decode('anZNSVE/Sztda05uMj8xS0Q1SD4=') b'jvMIQ?K;]kNn2?1KD5H>' >>> base64_decode('anZNSVE_Sztda05uMj8xS0Q1SD4=', urlsafe=True) b'jvMIQ?K;]kNn2?1KD5H>'