I need tos solve some small exercises, where I need to do some xor'ing on some strings. I found this super simple code, which simply encodes, and decodes:
hex_str = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d"
decoded = hex_str.decode("hex")
# I'm killing your brain like a poisonous mushroom
base64_str = decoded.encode("base64")
# SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t
This fails with:
AttributeError: 'str' object has no attribute 'decode'
Which I guess makes sense, if there no decode
attribute, then there is no decode attribute.
But what do I do then? I literally just want to convert between types. (from string to bytes, to base64)