⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 9-5 利用正则实现加密解密.htm

📁 JAVASCRIPT完全自学手册,中源码的验证修订实例
💻 HTM
字号:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=GB2312" />
<title>9-5  利用正则实现加密解密</title>
<!-- 样式表 -->
<style>
* { font-size:12px; font-family:宋体, Arial; } /*规定了所有的字体样式*/
body { background-color:buttonface; border-width:0px; margin:0px; padding:5px; }
textarea { border-width:1px; width:200px; height:100px; margin-bottom:5px; }
input { border-width:1px; margin-bottom:5px; }
</style>
<script>
function encode(){
    $("t2").value = escape($("t1").value.replace(/./g, replace_core));
    $("t3").value = escape($("t1").value);
}

function decode(){
    $("t1").value = unescape($("t2").value).replace(/./g, replace_core);
    $("t3").value = escape($("t1").value);
}

function replace_core(chr){
    var chr_code, chr_index;
    chr_code = chr.charCodeAt(0);
    chr_index = arguments[arguments.length-2];
    return(String.fromCharCode(chr_code^chr_index));
}

function $(str){ return(document.getElementById(str)); }
</script>
</head>
<body style="overflow:auto;">
<table width="100%" >
    <tr>
        <td><b>明文:</b></td>
        <td rowspan="2">
            <input type="button" value="加密" onclick="encode();">
            <br/>
            <input type="button" value="解密" onclick="decode();">
        </td>
        <td><b>密文:</b></td>
        <td><b>escape编码:</b></td>
    </tr>
    <tr>
        <td><textarea id="t1"></textarea></td>
        <td><textarea id="t2"></textarea></td>
        <td><textarea id="t3"></textarea></td>
    </tr>
</table>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -