Cryptopals: Convert hex to base64
Sep 13, 2020 Update: Aug 28, 2021
The challenge#
The string:
49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d
Should produce:
SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t
So go ahead and make that happen. You'll need to use this code for the rest of the exercises.
Always operate on raw bytes, never on encoded strings. Only use hex and base64 for pretty-printing.
The solution#
atob('49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d')
does not result in SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t
, so it is obviously something beyond what immediately comes to the mind.
💭 49276d206b69...
is in hex. So maybe split the long string into pairs of two and convert them to their corresponding ASCII characters. Let's see.
Notes#
- I got it working without having to work with raw bytes. Not sure, if it's a bad or good thing. Most likely bad 🙃, but I did solve the challenge.
- Don't forget to convert to ASCII characters, don't leave it at ASCII code.
- "I'm killing your brain like a poisonous mushroom"