Usage:Code:String.prototype.aEncode = function(){ var ar = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,.!?/&#%=+-~_*'.split(''), a = this.length, x, y = '', z; var b = ar.length; if((a+2)%2 == 0){ for(i = 0; i<a;i++){ if((i+2)%2 == 0){ x = ((ar.indexOf(this[i])-a)+b)%b; y += ar[x]; } else{ x = ((ar.indexOf(this[i])+a)+b)%b; y += ar[x]; } } } else{ for(i = 0; i<a;i++){ if((i+2)%2 == 0){ x = ((ar.indexOf(this[i])+a)+b)%b; y += ar[x]; } else{ x = ((ar.indexOf(this[i])-a)+b)%b; y += ar[x]; } } } return y; } String.prototype.aDecode = function(){ var ar = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,.!?/&#%=+-~_*'.split(''), a = this.length, x, y = '', z; var b = ar.length; if((a+2)%2 == 0){ for(i = 0; i<a;i++){ if((i+2)%2 == 0){ x = ((ar.indexOf(this[i])+a)+b)%b; y += ar[x]; } else{ x = ((ar.indexOf(this[i])-a)+b)%b; y += ar[x]; } } } else{ for(i = 0; i<a;i++){ if((i+2)%2 == 0){ x = ((ar.indexOf(this[i])-a)+b)%b; y += ar[x]; } else{ x = ((ar.indexOf(this[i])+a)+b)%b; y += ar[x]; } } } return y; }
Not exactly sure why someone would use it, but it's cool. I guess it would be nice for like...keeping messages or a password secret.Code:'somestring'.aEncode();//iycoiDhsdq
Results 1 to 8 of 8
Threaded View
- 25 Jul. 2013 12:30am #1
So...I made my own encoding method...