Skip to content

Instantly share code, notes, and snippets.

@iampeterbanjo
Created November 9, 2012 21:21
Show Gist options
  • Save iampeterbanjo/4048350 to your computer and use it in GitHub Desktop.
Save iampeterbanjo/4048350 to your computer and use it in GitHub Desktop.
decypher niantic crypto text
/*
* 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