The code is as follows:
Function Encrypt (STR, PWD) {
IF (PWD == Null || PWD.LENGTH <= 0) {
"" ""
Return NULL;
}
VAR PRAND = ""
For (var i = 0; i PRAND = PWD.CHARCODEAT (i) .tostring (); } Var spos = math.floor (PRAND.LENGTH / 5); Var Mult = PARSEINT (PRAND.CHARAT (SPOS) PRAND.CHARAT (SPOS * 2) PRAND.CHARAT (SPOS * 3) PRAND.CHARAT (SPOS * 4) PRAND.CHARAT (SPOS * 5)); Var INCR = Math.ceil (pwd.length / 2); Var moduume = Math.Pow (2, 31) - 1; IF (MULT <2) { Alert ("Algorithm Cannot Find A Suitable Hash. Please choos a Different Password. / Npossible Considerations Are To Choose a More Complex or Longer Password."); Return NULL; } Var Salt = math.Round (Math.random () * 1000000000)% 100000000; PRAND = SALT; While (PRAND.LENGTH> 10) { PRAND = (PRASEINT (PRAND.SUBSTRING (0, 10)) PARSEINT (PRAND.SUBSTRING (10, PRAND.LENGTH)). TOSTRING (); } PRAND = (MULT * PRAND INCR)% MODU; VAR ENC_CHR = "" VAR ENC_STR = "" For (var i = 0; i ENC_CHR = PARSEINT (Str.Charcodeat (i) ^ Math.Floor ((PRAND / MODU) * 255))) IF (ENC_CHR <16) { ENC_STR = "0" enc_chr.tostring (16); Else ENC_STR = Enc_chr.tostring (16); PRAND = (MULT * PRAND INCR)% MODU; } Salt = Salt.toString (16); While (Salt.Length <8) Salt = "0" SALT; ENC_STR = SALT; Return ENC_STR; } Function Decrypt (STR, PWD) { IF (str == null || str.length <8) { Alert ("A Salt Value Could NOT BE Extracted from the Encrypted Message Because It's length."); Return; } IF (PWD == Null || PWD.LENGTH <= 0) { Alert ("Please Enter a Password with Which to Decrypt the Message."); Return; } VAR PRAND = "" For (var i = 0; i PRAND = PWD.CHARCODEAT (i) .tostring (); } Var spos = math.floor (PRAND.LENGTH / 5); Var Mult = PARSEINT (PRAND.CHARAT (SPOS) PRAND.CHARAT (SPOS * 2) PRAND.CHARAT (SPOS * 3) PRAND.CHARAT (SPOS * 4) PRAND.CHARAT (SPOS * 5)); Var INCR = Math.Round (pwd.length / 2); Var moduume = Math.Pow (2, 31) - 1; Var Salt = PARSEINT (Str.Substring (Str.Length - 8, Str.Length), 16); Str = str.substring (0, str.Length - 8); PRAND = SALT; While (PRAND.LENGTH> 10) { PRAND = (PRASEINT (PRAND.SUBSTRING (0, 10)) PARSEINT (PRAND.SUBSTRING (10, PRAND.LENGTH)). TOSTRING (); } PRAND = (MULT * PRAND INCR)% MODU; VAR ENC_CHR = "" VAR ENC_STR = "" For (var i = 0; i ENC_CHR = PARSEINT (Parseint (Str.Substring (I, I 2), 16) ^ Math.Floor ((PRAND / MODU) * 255); ENC_STR = String.Fromcharcode (ENC_CHR); PRAND = (MULT * PRAND INCR)% MODU; } Return ENC_STR; } // end -> script> td> tr> td> td> td> tr> td> tr> table> center> form> [ctrl a all-select prompt: You can modify some code first, then run the code again]