欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

security.js實現(xiàn)的RSA加密功能示例

 更新時間:2018年06月06日 12:07:00   作者:南喬幾經(jīng)秋  
這篇文章主要介紹了security.js實現(xiàn)的RSA加密功能,結(jié)合實例形式分析了基于security.js進行RSA加密的相關(guān)操作技巧,需要的朋友可以參考下

本文實例講述了security.js實現(xiàn)的RSA加密功能。分享給大家供大家參考,具體如下:

在項目中遇到要對用戶輸入的密碼進行RSA加密的需求,總結(jié)一下實現(xiàn)過程:

<html>
<head>
<meta charset="utf-8" />
<title>www.dbjr.com.cn JS rsa加密</title>
</head>
<body>
  <div>
   <input type="text" id="pwd" placeholder="請輸入密碼"/><br />
   <input type="text" id="key1" placeholder="請輸入modulus參數(shù)"/><br />
   <input type="text" id="key2" placeholder="請輸入exponent參數(shù)"/>
   <button id="btn">加密</button><br />
   <input type="text" id="pwd1" placeholder="加密后"/>
  </div>
 <script type="text/javascript" src="../RSA加密/security.js">
 //引入security.js文件
 </script>
 <script>
  var btn = document.getElementById('btn');
  btn.onclick = function(){
   var pwd = document.getElementById('pwd').value;
   var modulus = document.getElementById('key1').value;
   var exponent = document.getElementById('key2').value;
   //加密
   var key = RSAUtils.getKeyPair(exponent, "", modulus);
   var apwd = RSAUtils.encryptedString(key, pwd);
   //加密后的密碼;
   document.getElementById('pwd1').value = apwd;
  }
 </script>
</body>
</html>

這里的exponent參數(shù)和modulus參數(shù)講道理是要從后臺獲取的,這里寫做輸入框獲取是作測試用。

security.js點擊此處本站下載

PS:關(guān)于加密解密感興趣的朋友還可以參考本站在線工具:

在線RSA加密/解密工具:
http://tools.jb51.net/password/rsa_encode

文字在線加密解密工具(包含AES、DES、RC4等):
http://tools.jb51.net/password/txt_encode

在線編碼轉(zhuǎn)換工具(utf-8/utf-32/Punycode/Base64):
http://tools.jb51.net/transcoding/decode_encode_tool

BASE64編碼解碼工具:
http://tools.jb51.net/transcoding/base64

在線MD5/hash/SHA-1/SHA-2/SHA-256/SHA-512/SHA-3/RIPEMD-160加密工具:
http://tools.jb51.net/password/hash_md5_sha

在線sha1/sha224/sha256/sha384/sha512加密工具:
http://tools.jb51.net/password/sha_encode

更多關(guān)于JavaScript相關(guān)內(nèi)容可查看本站專題:《JavaScript加密解密技巧匯總》、《JavaScript查找算法技巧總結(jié)》、《JavaScript錯誤與調(diào)試技巧總結(jié)》、《JavaScript數(shù)據(jù)結(jié)構(gòu)與算法技巧總結(jié)》、《JavaScript遍歷算法與技巧總結(jié)》及《JavaScript數(shù)學運算用法總結(jié)

希望本文所述對大家JavaScript程序設(shè)計有所幫助。

相關(guān)文章

最新評論