加密与解密 第4版

加密与解密 (豆瓣)
https://book.douban.com/subject/3091212/

《加密与解密(第4版)》-看雪安全论坛
https://bbs.pediy.com/forum-99.htm

[注意]《加密与解密(第4版)》勘误收集-《加密与解密(第4版)》-看雪安全论坛
https://bbs.pediy.com/thread-247429.htm

[快讯]十年磨一剑!《加密与解密(第4版)》已上市!-《加密与解密(第4版)》-看雪安全论坛
https://bbs.pediy.com/thread-230052.htm

[公告] 第三届看雪2019安全开发者峰会(SDC)议题征集-7月20日国家会议中心-『茶余饭后』-看雪安全论坛
https://bbs.pediy.com/thread-248796.htm

转载于:https://www.cnblogs.com/rgqancy/p/10999689.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
java加密解密 function encrypt(str, pwd) { if(pwd == null || pwd.length <= 0) { alert("Please enter a password with which to encrypt the message."); return null; } var prand = ""; for(var i=0; i<pwd.length; 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 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; 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); } 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 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<pwd.length; 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 modu = 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 = (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; i<str.length; i+=2) { 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; }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值