Skip to content

Instantly share code, notes, and snippets.

@russelyang
Created September 5, 2014 05:37
Show Gist options
  • Save russelyang/a25f7a120d59b2f55dbb to your computer and use it in GitHub Desktop.
Save russelyang/a25f7a120d59b2f55dbb to your computer and use it in GitHub Desktop.
var decrypt = function(text, key) {
var src = "abcdefghijklmnopqrstuvwxyz";
var cipher = {};
for(var i=0 ; i<26; i++) {
cipher[src[(i+key) % 26]] = src[i];
}
//console.log(cipher);
var output = [];
for(var j=0; j < text.length; j++) {
output[j] = cipher[text[j]];
}
return output.join('');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment