Skip to content

Instantly share code, notes, and snippets.

@ojame
Last active April 11, 2016 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ojame/c36699aeab3c8c0c509e747e6609c0f1 to your computer and use it in GitHub Desktop.
Save ojame/c36699aeab3c8c0c509e747e6609c0f1 to your computer and use it in GitHub Desktop.
var input = '49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d';
var result = 'SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t';
function hexToPT(hex) {
var str = '';
for (var i = 0; i < hex.length; i += 2) {
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
}
return str;
}
var converted = window.btoa(hexToPT(input));
console.log(converted === result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment