Usernames and passwords are not encrypted. Instead, the username and password are concatenated together using a : symbol to form a single string: username:password. This string is then encoded using base64. >>> import base64 >>> >>> auth = "username:password" >>> auth_bytes = auth.encode('ascii') # convert to bytes >>> auth_bytes b'username:password' >>> >>> encoded = base64.b64encode(auth_bytes)