Created
November 9, 2012 21:21
-
-
Save iampeterbanjo/4048350 to your computer and use it in GitHub Desktop.
decypher niantic crypto text
This file contains 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
/* | |
* copy and paste into your browser's console to run and | |
* then use like so | |
* interprete("Jajwd tujwfynts wjfhmjx f wnxp-fxxjxxrjsy xyflj. Fy ymnx utnsy rd ijyjwrnsfynts nx ymfy snfsynh nx hfzxnsl rtwj ywtzgqj ymfs ny nx btwym") | |
*/ | |
// simple deciphering scheme | |
var alphabet = "abcdefghijklmnopqrstuvwxyz"; | |
var sillyAlphabet = "vwxyzabcdefghijklmnopqrstu"; | |
var decrypt = {}; | |
for(var i = 0, limit = alphabet.length; i < limit; i++){ | |
decrypt[alphabet[i]] = sillyAlphabet[i]; | |
} | |
// enter the encrypted text and tell us what it | |
// means | |
// @param {string} jibberish | |
// @return {string} result | |
function interprete(jibberish){ | |
var result = [], | |
jib = ""; | |
for(var i = 0, limit = jibberish.length; i < limit; i++){ | |
jib = jibberish[i].toLowerCase(); | |
if( jib && decrypt[jib]){ | |
result.push(decrypt[jib]); | |
} else { | |
result.push(" "); | |
} | |
} | |
return result.join(''); | |
} | |
// sanity check that our scheme works | |
function testInterprete(){ | |
if(console && console.log){ | |
console.log( "is" == interprete("nx") ); | |
console.log( "every" == interprete("jajwd") ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment