Skip to content

Instantly share code, notes, and snippets.

@passcod
Forked from jason-s13r/LOLcryption.js
Created November 2, 2012 08:34
Show Gist options
  • Save passcod/3999502 to your computer and use it in GitHub Desktop.
Save passcod/3999502 to your computer and use it in GitHub Desktop.
enLOLcryption.
String.prototype.enlolcrypt = function (cipher) {
cipher = cipher || "aeoiubcdfghjklmnpqrstvwxyz";
return this.split("").map(function (T) {
var c = /[A-Z]/.test(T), T = T.toLowerCase(), i = cipher.indexOf(T);
if (/[^a-z]/.test(T)) { return T; }
if ((new RegExp("["+cipher.substr(0,5)+"]")).test(T)) {
T = cipher[(i+2)%5];
} else {
T = cipher[(i+5)%21+5];
}
return c?T.toUpperCase():T;
}).join("");
}
String.prototype.delolcrypt = function (cipher) {
cipher = cipher || "aeoiubcdfghjklmnpqrstvwxyz";
return this.split("").map(function (T) {
var c = /[A-Z]/.test(T), T = T.toLowerCase(), i = cipher.indexOf(T),
mod = function(a,n) {return ((a%n)+n)%n;};
if (/[^a-z]/.test(T)) { return T; }
if ((new RegExp("["+cipher.substr(0,5)+"]")).test(T)) {
T = cipher[mod(i-2,5)];
} else {
T = cipher[mod(i-15,21)+5];
}
return c?T.toUpperCase():T;
}).join("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment