We can use different keywords to implement the string encoding from base64 module. Start by importing the module like so: import base64 # then, either: "the string to be converted".encode("base64") or add the "strict" option "the string to be converted".encode("base64", "strict") or base64.encode("the string to be converted") base64.encodestring("the string to be converted") base64.b64encode("the string to be converted") base64.standard_b64encode("the string to be converted") base64.urlsafe_b64encode("the url string to be converted") The first two methods will yield \n as the tail of the output. Those could be "dangerous" for authentication. Because if we forgot to include the front-end converter (such as in JavaScript , like adding replace or other), or other string filter(s) within the Python itself, the stuff would fail. And if the certain API ...