functionEncrypt (str, pwd) {if(str = = "")return""; STR=Escape (str); if(!pwd | | pwd = = "") { varPWD = "1234"; } pwd=Escape (PWD); if(pwd = =NULL|| Pwd.length <= 0) {alert ("Please enter a password with which to encrypt the message."); return NULL; } varPrand = ""; for(varI = 0; I < Pwd.length; i++) {Prand+=pwd.charcodeat (I). toString (); } varSpos = Math.floor (PRAND.LENGTH/5); varmult = parseint (Prand.charat (Spos) + Prand.charat (Spos * 2) + Prand.charat (Spos * 3) + Prand.charat (Spos * 4) + Prand.char At (Spos * 5)); varINCR = Math.ceil (pwd.length/2); varModu = Math.pow (2, 31)-1; if(Mult < 2) {alert ("Algorithm cannot find a suitable hash. Please choose a different password. /n Possible considerations is to choose a more complex or longer password. "); return NULL; } varSalt = Math.Round (Math.random () * 1000000000)% 100000000; Prand+=Salt; while(Prand.length > 10) {Prand= (parseint (prand.substring (0)) + parseint (prand.substring (10, Prand.length)). ToString (); } Prand= (mult * prand + incr)%Modu; varENC_CHR = ""; varEnc_str = ""; for(varI = 0; I < Str.length; i++) {ENC_CHR= parseint (Str.charcodeat (I) ^ Math.floor ((prand/modu) * 255)); if(ENC_CHR < 16) {Enc_str+ = "0" + enc_chr.tostring (16); } ElseEnc_str+ = enc_chr.tostring (16); Prand= (mult * prand + incr)%Modu; } Salt= Salt.tostring (16); while(Salt.length < 8) Salt = "0" +Salt; Enc_str+=Salt; returnEnc_str; }
Call: Encrypt (Name, "")
JS Encryption Method Encrypt