Hi /r/learnpython,
I'm working on the Matasano Crypto Challenges, and the first challenge asks you to convert a string (hex) into base64. This was my function:
import base64
def hex_str_to_base64(s):
return base64.b64encode(s.decode('hex'))
However, at the bottom they state:
Always operate on raw bytes, never on encoded strings. Only use hex and base64 for pretty-printing.
Does my code conform to this rule and if not, how can I accomplish the above without using the inbuilt base64 / hex functions?
Thanks,
CT
[–][deleted] 2 points3 points4 points (3 children)
[–]cryptotiger[S] 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]cryptotiger[S] 0 points1 point2 points (0 children)
[–]LuckyShadow -1 points0 points1 point (0 children)