0

So Ive got a string of:
YDNhZip1cDg1YWg4cCFoKg==
that needs to be decoded using Pythons Base64 module.

Ive written the code

import base64

test = 'YDNhZip1cDg1YWg4cCFoKg=='
print(test)
print(base64.b64decode(test))

which gives the answer
b'`3afup85ah8p!h'
when, according to the website decoders Ive used, its really

`3afup85ah8p!h

Im guessing that its decoding the additional quotes.
Is there some way that I can save this variable with a delimiter, as another type of variable, or run the b64encode on a section of the string as slice doesnt seem to work?

Shiroslullaby
  • 119
  • 1
  • 2
  • 9

1 Answers1

2

b' is Python's way of delimiting data from bytes, see: What does the 'b' character do in front of a string literal?

i.e., it is decoding it correctly.

Community
  • 1
  • 1
Benjamin Murphy
  • 108
  • 1
  • 8
  • Ok thanks. I need to use the returned value so Im hoping that this additional characters wont cause a problem or using .decode("utf-8") will take care of it. (Being fed back to a POST to a website looking for a specific value) – Shiroslullaby Jan 30 '15 at 05:29