|
Description: Encrypts/decrypts strings.
Syntax: string.cipher(boolean)
var alpha = "czefgnxhrkl.aoptysb vmqdujwi" String.prototype.cipher = function(a) { var e = [], x = 0; if(a) while(x < this.split("..").length) e.push(alpha.charAt(this.split("..")[x ++])); else while(x < this.length) e.push(alpha.indexOf(this.charAt(x ++))); return e.join((/\.\./.test(this) ? "" : "..")); }
Example: var d = "abc defg".cipher(); // encrypt alert(d.cipher()); alert(d..cipher().cipher(true)); // alert decryption
|
|
|