----先看效果(输入需要加密或者解密的字符串并点击按钮试试)

字符串:
加密key: key1=123456
加密结果:  
解密结果:  

 

--看代码(无需任何修改直接运行)

 

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--届时请下载到本地-->
    <script type="text/javascript" src="https://blog-static.cnblogs.com/files/-hao/des.js"></script>
    <script>
        function getStrEnc() {
            //待加密字符串
            var str = document.getElementById("str").value;
            //第一个参数必须;第二个、第三个参数可选
            var key1 = document.getElementById("key1").innerText;
            var key2 = document.getElementById("key2").innerText;
            var key3 = document.getElementById("key3").innerText;
            //加密方法
            var enResult = strEnc(str, key1, key2);
            //解密方法
            //var deResult = strDec(enResult,key1,key2);
            //展示结果
            document.getElementById("enStr").innerText = enResult;
            //document.getElementById("dnStr").innerText = deResult;
        }

        function getDeResult() {
             var str = document.getElementById("str").value;
            var key1 = document.getElementById("key1").innerText;
            var key2 = document.getElementById("key2").innerText;
            var key3 = document.getElementById("key3").innerText;
            var deResult = strDec(str, key1, key2);
            document.getElementById("dnStr").innerText = deResult;
        }

/**/</script>
</head>
<body>

    <p><input onclick="getStrEnc()" type="button" value="获取加密结果" /> <input onclick="getDeResult()" type="button" value="获取解密结果" /></p>
    <table>
        <tbody>
            <tr>
                <td align="left">字符串:</td>
                <td>
                <textarea id="str" style="width: 500px; height: 200px;"></textarea>
                </td>
            </tr>
            <tr>
                <td>加密key:</td>
                <td>key1=<span id="key1">1</span>;key2=<span id="key2">2</span>;key3=<span id="key3">3</span></td>
            </tr>
            <tr>
                <td align="left">加密结果:</td>
                <td align="left">&nbsp;<label id="enStr"></label></td>
            </tr>
            <tr>
                <td align="left">解密结果:</td>
                <td align="left">&nbsp;<label id="dnStr"></label></td>
            </tr>
        </tbody>
    </table>
</body>
</html>
View Code

 

posted on 2019-10-10 15:21  许一朵岁月  阅读(1497)  评论(0编辑  收藏  举报