This was an old post I originally wrote the 24th of October 2018. I recently discovered it in the drafts of this blog. At the time, I was planning to do this challenge on many other languages, but ended up abandoning. I decided to publish it today. It is a short one, enjoy!
Cloudflare’s email-decoder in one line
I’ve recently “decrypted” Cloudflare’s email-decode.js,
this is my take on writing some one line decoders for it.
Thus ....
will be “decrypted” into l33t@antipatico.ml
Why one line?
It’s fun to code-golf from time to time.
Javascript
var cfDecrypt = ciphertext => [...ciphertext].slice(2).map(x => parseInt(x,16)).map((x,i,arr) => (i%2)? x+arr[i-1]*16 : -1).filter(x => x != -1).map(x => x ^ parseInt(ciphertext.substr(0,2),16)).map(x => String.fromCharCode(x)).join("");
Python
cfDecrypt = lambda emailCipher : "".join([ chr(int(emailCipher[x:x+2], 16)^int(emailCipher[:2],16)) for x in range(2, len(emailCipher), 2)])