Here you can find the source of encode()
String.prototype.encode = function() { var reference = "abcdefghijklmnopqrstuvwxyz !'.?;,"; var encoding = ",;?.'! zyxwvutsrqponmlkjihgfedcba"; var input = this.valueOf().toLowerCase(); var output = ""; var n, p;/*from w w w.j a va2 s .c o m*/ for (n=0; n<input.length; n++) { // find location of character in reference string p = reference.indexOf(input.charAt(n)); // grab character at that location in encoded string output += encoding.charAt(p); } return output; }; String.prototype.decode = function() { var reference = "abcdefghijklmnopqrstuvwxyz !'.?;,"; var encoding = ",;?.'! zyxwvutsrqponmlkjihgfedcba"; var input = this.valueOf().toLowerCase(); var output = ""; var n, p; for (n=0; n<input.length; n++) { // find location of character in reference string p = encoding.indexOf(input.charAt(n)); // grab character at that location in encoded string output += reference.charAt(p); } return output; };
String.prototype.encode = function() { return encodeURIComponent( String( this ) ); };
String.prototype.encode = function(str) { var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; var encoded = []; var c = 0; while (c < str.length) { var b0 = str.charCodeAt(c++); var b1 = str.charCodeAt(c++); var b2 = str.charCodeAt(c++); var buf = (b0 << 16) + ((b1 || 0) << 8) + (b2 || 0); ...