Skip to content

Instantly share code, notes, and snippets.

@brianteachman
Created September 29, 2012 15:51
Show Gist options
  • Save brianteachman/3804427 to your computer and use it in GitHub Desktop.
Save brianteachman/3804427 to your computer and use it in GitHub Desktop.
ROT-13 letter substitution cipher. For obfuscation because of virtually absent, level of security.
//http://en.wikipedia.org/wiki/Rot13
//var name = "Brian Teachman";
//var token = "Oevna Grnpuzna";
function rot13(name) {
var lt1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
var lt2 = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm ";
var result = "";
for (var char=0; char<name.length; char++) {
for (var i=0; i<lt1.length; i++) {
if (name[char] === lt1[i]) {
result += lt2[i];
}
}
}
return result;
}
//result = rot13("name");
anzr = rot13("Brian Teachman");
console.log(anzr); // Oevna Grnpuzna
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment