hacktoolkit / django-htk

A set of apps, utilities, middlewares, etc for Django
MIT License
140 stars 46 forks source link

refactor: ♻️ Make b64encode Python 2/3 compat #407

Closed goztrk closed 11 months ago

goztrk commented 11 months ago

Status

READY

Description

base64.b64encode requires encoded bytes in Python 3 but it works with str in Python 2. The result of this function is bytes in Python 3 and str in Python 2.

Encoding the data with utf-8 before passing to base64.b64encode works both for Python 2 and 3. If the returning value is bytes (this only happens with Python 3) it needs to be decoded with utf-8