Created
October 26, 2016 16:34
-
-
Save LottieVixen/e1a87a521acf128b7a7eab83ee32fde1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //--INIT | |
| h2b = {a:['0' ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' ,'a' ,'b' ,'c' ,'d' ,'e' ,'f'], | |
| b:['0000','0001','0010','0011','0100','0101','0110','0111','1000','1001','1010','1011','1100','1101','1110','1111']}; | |
| b64Arr= ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', | |
| 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', | |
| '0','1','2','3','4','5','6','7','8','9','+','/']; | |
| hexa = '1c0111001f010100061a024b53535009181c'; | |
| hexb = '686974207468652062756c6c277320657965'; | |
| bin = ''; | |
| for (var i = 0; i <= hex.length-1; i++) { | |
| part = hex.slice(i,i+1); | |
| //console.log(part); | |
| //console.log(h2b['a'].indexOf(part)); | |
| bin += h2b.b[h2b.a.indexOf(part)]; | |
| }; | |
| console.log('Binary\n'+bin+'\n\n'); | |
| outs = 0; | |
| for (var i = 0; i <= bin.length-1; i+=6) { | |
| part = bin.slice(i,i+6); | |
| b64+=b64Arr[parseInt(part,2)]; | |
| //* | |
| outs+=1; | |
| //console.log(part); | |
| //console.log(h2b['a'].indexOf(part)); | |
| //bin += h2b.b[h2b.a.indexOf(part)]; | |
| process.stdout.write(part+' '); | |
| if (outs == 7){ | |
| console.log(''); | |
| outs = 0; | |
| //*/ | |
| } | |
| }; | |
| console.log('\n\n'); | |
| console.log('base64\n'+b64+'\n\n'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment