conversions.binary_to_base64

References for better understanding: https://en.wikipedia.org/wiki/Base64

Attributes

BITS_TO_B64

Functions

bin_to_base64(→ str)

Convert a binary value to its base64 equivalent

Module Contents

conversions.binary_to_base64.bin_to_base64(bin_str: str) str

Convert a binary value to its base64 equivalent

>>> bin_to_base64("000001")
'AB'
>>> bin_to_base64("0")
'A'
>>> bin_to_base64("1")
'B'
>>> bin_to_base64("-1")
'-B'
>>> bin_to_base64(" -000001 ")
'-AB'
>>> bin_to_base64("0-0")
Traceback (most recent call last):
    ...
ValueError: Non-binary value was passed to the function
>>> bin_to_base64("")
Traceback (most recent call last):
    ...
ValueError: Empty string was passed to the function
conversions.binary_to_base64.BITS_TO_B64