jsencrypt.html 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>RSA加密</title>
  6. <link href="AFrontEnd/css/special.css" rel="stylesheet" />
  7. </head>
  8. <body class="sp-page-center" onkeydown="keyLogin();">
  9. <div class="sp-box" style="line-height: 30px">
  10. <div class="sp-page" style="width: 10%;">内容:</div>
  11. <textarea style="width: 80%; resize: none; " rows="10" class="sp-textarea" id="content"></textarea>
  12. <div class="sp-page sp-pull-right" style="width: 10%;"><button class="sp-btn-blue" onclick="encrypt()">加密</button></div>
  13. <div class="sp-page" style="width: 20%;">加密内容:</div>
  14. <textarea style="width: 80%; resize: none; " rows="10" class="sp-textarea" id="content2"></textarea>
  15. <div class="sp-page" style="width: 20%;">base64加密内容:</div>
  16. <textarea style="width: 80%; resize: none; " rows="10" class="sp-textarea" id="content3"></textarea>
  17. </div>
  18. <script src="AFrontEnd/js/jquery/jquery-1.8.3.min.js"></script>
  19. <script src="js/jsencrypt.js"></script>
  20. <script src="js/base64.js"></script>
  21. <script>
  22. var base64 = new Base64();
  23. var key="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgUCcDOMnAD6DXdRhPv7rsV3r9BTjFSog8IijWC9HqxxO2KrzQa_lDi9ox5_fwCSueifWykEfR55JyLdG-gnDywbErrdCMoNlq4-5aSFiieY1-0GsZYUmpN5FSvx_zPyjHzOQZgjoZ4ugzNG4cscRWbE6xH_BRfjUwQwhsecBBbzUw36KsXgpJD8UOadtx6LQTnHy93fWm1n-zmyiq3fuAOjv2VuJ8XOqfoVv6qljH_DgZ_e7CSGnhTEeKjGdys_qm2AVll3PejG4ufmj_bjMXIr0QY6YfQILK2NsLBLduqNWnH_wi8DTg4xfbcJi_Dm8SlXP4NiX8IVTTdlj4o-soQIDAQAB"
  24. function keyLogin() {
  25. if (event.keyCode == 13) //回车键的键值为13
  26. {
  27. encrypt();
  28. }
  29. }
  30. function encrypt() {
  31. var time1 = new Date().getTime();
  32. var jsencrypt = new JSEncrypt()
  33. jsencrypt.setPublicKey(key)
  34. var encryptMsg = jsencrypt.encrypt($("#content").val())
  35. $("#content2").val(encryptMsg)
  36. $("#content3").val(base64.encode(encryptMsg))
  37. var time2 = new Date().getTime();
  38. console.log(encryptMsg)
  39. console.log(time1, time2)
  40. }
  41. var n = 0;
  42. document.addEventListener("visibilitychange", function () {
  43. if (document.visibilityState == "visible") {
  44. n++
  45. console.log("jsencrypt.html" + n)
  46. }
  47. })
  48. </script>
  49. </body>
  50. </html>