Commit 53bfd31b authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Refactor b64encode()

parent f5a9acc0
......@@ -61,14 +61,14 @@ def b64decode(data: Union[str, bytes]) -> bytes:
return base64.b64decode(data)
def b64encode(data, return_type=str):
def b64encode(data: Union[str, bytes]) -> str:
if not data:
raise ValueError('No data to encode')
if isinstance(data, str):
data = data.encode()
result = base64.b64encode(data)
if return_type == bytes:
return result
return result.decode()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment