微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript将url中的参数加密解密代码

今天在做一个老项目时,遇到一个需求,在javascript将url中的参数加密解密,从网上找发现了这段有用的代码

代码如下:
arat(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 modu = Math.pow(2,31) - 1; if(mult < 2) { alert("Algorithm cannot find a suitable hash. Please choose 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 = (parseInt(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; ICould not be extracted from the encrypted message because it's length is too short. The message cannot be decrypted."); 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 10) { prand = (parseInt(prand.substring(0,prand.length))).toString(); } prand = (mult * prand + incr) % modu; var enc_chr = ""; var enc_str = ""; for(var I=0; I

以后碰到加密解密问题,直接将上述代码写成一个js文件,就搞定。省事了。。。。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐