123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <title>解密</title>
- <link href="AFrontEnd/css/special.css" rel="stylesheet" />
- </head>
- <body class="sp-page-center" onkeydown="keyLogin();">
- <div class="sp-box" style="line-height: 30px">
- <div class="sp-page" style="width: 10%;">加密内容:</div>
- <textarea style="width: 80%; resize: none; " rows="10" class="sp-textarea" id="content1"></textarea>
- <div class="sp-page sp-pull-right" style="width: 10%;"><button class="sp-btn-blue" onclick="decrypt()">解密</button></div>
- </div>
- <div class="sp-box" style="line-height: 30px">
- <div class="sp-page" style="width: 10%;">解密内容:</div>
- <textarea style="width: 80%; resize: none; " rows="10" class="sp-textarea" id="content2"></textarea>
- <div class="sp-page sp-pull-right" style="width: 10%;"><button class="sp-btn-blue" onclick="encrypt()">加密</button></div>
- </div>
- <script src="AFrontEnd/js/jquery/jquery-1.8.3.min.js"></script>
- <script src="js/sm4.js"></script>
- <script>
- var s4 = new SM4Util();
- function keyLogin() {
- if (event.keyCode == 13) //回车键的键值为13
- {
- if ($("#content1").val() != "") {
- decrypt();
- } else {
- encrypt();
- }
- }
- }
- function encrypt() {
- var content = $("#content2").val()
- $("#content1").val(s4.encryptData_CBC(content))
- }
- function decrypt() {
- var time1 = new Date().getTime();
- console.log(time1)
- var content = $("#content1").val().replace(/"+/g, "").replace(/\s+/g, "");
- var data = s4.decryptData_CBC(content).replace(/\u0000|\u0001|\u0002|\u0003|\u0004|\u0005|\u0006|\u0007|\u0008|\u0009|\u000a|\u000b|\u000c|\u000d|\u000e|\u000f|\u0010|\u0011|\u0012|\u0013|\u0014|\u0015|\u0016|\u0017|\u0018|\u0019|\u001a|\u001b|\u001c|\u001d|\u001e|\u001f|\u007F/g, "")
- $("#content2").val(data)
- console.log(JSON.parse(data))
- console.log(new Date().getTime() - time1)
- }
- var n = 0;
- document.addEventListener("visibilitychange", function () {
- if (document.visibilityState == "visible") {
- n++
- //console.log("s4decrypt.html" + n)
- }
- })
- sessionStorage.setItem("operate",0)
- var mytime = setTimeout("Timeout()", 6000);
- function resetTime() {
- n = 0;
- clearTimeout(mytime);
- mytime = setTimeout("Timeout()", 6000);
- }
- function Timeout() {
- //alert("登录超时!")
- }
- var n = 0;
- setInterval(function () {
- n = n + 1;
- //console.log(n)
- if (sessionStorage.getItem("operate") == 1) {
- sessionStorage.setItem("operate", 0)
- resetTime()
- }
- },1000)
- document.documentElement.onkeydown = function () { sessionStorage.setItem("operate", 1) };
- document.documentElement.onmousemove = function () { sessionStorage.setItem("operate", 1) };
- document.documentElement.onmousedown = function () { sessionStorage.setItem("operate", 1) };
- </script>
- </body>
- </html>
|