I'm trying to encode a string using like so:
base64.b64encode(b'username\with\backslash:password')
but printing only the string results in this
print('username\\with\\backslash:password')
>> username\withackslash:password
When escaping the backslashes with another backslash it prints this
print('username\\with\\backslash:password')
>> username\with\backslash:password
which looks good. But when base64 encoding and afterwards decoding it adds the extra slashes though
encoded=base64.b64encode(b'username\\with\\backslash:password')
print(encoded)
print(base64.b64decode(encoded))
>> b'dXNlcm5hbWVcd2l0aFxiYWNrc2xhc2g6cGFzc3dvcmQ='
>> b'username\\with\\backslash:password'
It encodes the escaping characters as well.
The same without escaping
encoded=base64.b64encode(b'username\with\backslash:password')
print(encoded)
print(base64.b64decode(encoded))
>> b'dXNlcm5hbWVcd2l0aAhhY2tzbGFzaDpwYXNzd29yZA=='
>> b'username\\with\x08ackslash:password'
Anyone got me a hint on how to encoding this right? I need this for http request authorization headers and my encoded strings won't be accepted so far.