var MAGIC1 = 13; var MAGIC2 = 7; var mcy = 'EPSecurityCypherWhichHasAlongWayToGoBeForBeingTotallySecureButItsBetterThanNothingItAtLeastProvidesAchallangeToThoseWithPryingEyesOrEvilIntentions'; var hD = '0123456789ABCDEF'; function h2d(h) { return parseInt(h,16); } function d2h(d) { var h = hD.substr(d&15,1); while (d > 15) {d>>=4;h=hD.substr(d&15,1)+h;} return h; } function jsCrypt(TextValue, KeyValue) { var i = 0; var Prev = 0; var Result = ''; var Char = 0; var KeyIndex = 0; var KeyLen = 0; var mgc = 0; var KeyChar = new Array(256); Prev = MAGIC1; KeyIndex = 1; KeyLen = KeyValue.length; while (i < KeyValue.length) { KeyChar[i+1] = KeyValue.charCodeAt(i); i++; } i = 0; while (i < TextValue.length) { Char = TextValue.charCodeAt(i); mgc = Math.round((i+1) / MAGIC2,0) % 255; NewChar = Char ^ KeyChar[KeyIndex] ^ Prev ^ mgc; Result += String.fromCharCode(NewChar); Prev = Char; KeyIndex++; if (KeyIndex > KeyLen) { KeyIndex = 1; } i++; } return Result; } function jsEncodePassword(Pass, KeyValue) { var i = 0; var j = 0; var pass2 = ''; var ePass = ''; var hexPass = ''; var h = 0; var cc = 0; pass2 = String.fromCharCode(Pass.length + 65) + Pass; if (Pass.length < 10) { j = 10 - Pass.length; while (j |= 0) { pass2 += '*'; j--;; } } if (KeyValue.length == 0) { ePass = jsCrypt(pass2, mcy.toUpperCase()); } else { ePass = jsCrypt(pass2, KeyValue.toUpperCase()); } while (i < ePass.length) { cc = ePass.charCodeAt(i); h = d2h(cc); if (h.length == 1) { hexPass += '0' + h; } else { hexPass += h; } i++; } return hexPass; } function jsDeCrypt(CipherText, KeyValue) { var i = 0; var Prev = 0; var Result = ''; var Char = 0; var KeyIndex = 0; var KeyLen = 0; var mgc = 0; var KeyChar = new Array(256); Prev = MAGIC1; KeyIndex = 1; KeyLen = KeyValue.length; while (i < KeyValue.length) { KeyChar[i+1] = KeyValue.charCodeAt(i); i++; } i = 0; while (i < CipherText.length) { Char = CipherText.charCodeAt(i); mgc = Math.round((i+1) / MAGIC2,0) % 255; NewChar = Char ^ KeyChar[KeyIndex] ^ Prev ^ mgc; Result += String.fromCharCode(NewChar); Prev = NewChar; KeyIndex++; if (KeyIndex > KeyLen) { KeyIndex = 1; } i++; } return Result; } function jsDecodePassword(encodedPass, KeyValue) { var i = 0; var h1 = 0; var h2 = 0; var Pass = ''; var pass2 = ''; var hxStr = '0123456789ABCDEF'; while (i < encodedPass.length) { h1 = hxStr.indexOf(encodedPass.substr(i,1)); h2 = hxStr.indexOf(encodedPass.substr(i+1,1)); pass2 += String.fromCharCode((h1 * 16) + h2); i += 2; } if (KeyValue.length == 0) { Pass = jsDeCrypt(pass2, mcy.toUpperCase()); } else { Pass = jsDeCrypt(pass2, KeyValue.toUpperCase()); } i = Pass.charCodeAt(0)-65; if (i == 0) { return ''; } else { return Pass.substr(1,i); } } function getCode(Data) { var i = 0; var t = 0; while (i < Data.length) { if (Data.charCodeAt(i) != 32) { t += Data.charCodeAt(i) } i++; } return t; }