Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
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


newBookmarkLockedFalling