谁帮我写个加密和解密的函数?

阿良chjlcn 2006-02-06 06:51:39
谁帮我写个加密和解密的函数?
...全文
117 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
上海程序员3 2006-02-16
  • 打赏
  • 举报
回复
http://3http.com/3http/?t241410
mingxuan3000 2006-02-16
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/4555/4555090.xml?temp=6.498355E-02
mingxuan3000 2006-02-16
  • 打赏
  • 举报
回复
异或操作:

<html><head>
<title>用JS脚本实现信息加密</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta content="F.R.Huang(meizz梅花雪)//www.meizz.com" name="author">
<style>
* {font-size: 12px; color: #FFFFFF}
input, textarea {color: #000000}
</style>
<!-- http://expert.csdn.net/Expert/TopicView2.asp?id=1195120 -->

<script language="javascript">
function String.prototype.xor(key) //异或操作,也就是通用的对称加密、解密操作
{
var result = "";
for (var i=0; i<this.length; i++)
result += String.fromCharCode(this.charCodeAt(i)^key.charCodeAt(i%key.length));
return result;
}
function jia(e)
{
var key = key1.value;
var str = e.value
if (key == "" || str == "") return;
txtjia.value = escape(unescape(str).xor(key));
// txtjia.value = unescape(str).xor(key);
}
function jie(e)
{
var key = key2.value;
var str = e.value
if (key == "" || str == "") return;
txtjie.value = unescape(str).xor(key);
}
</script>

</head>
<body bgcolor=#000000>

<table width=100% height=100% align=center border=0>
<tr>
<td height=5% colspan=2 style="font-size: 16px; font-weight: bold">用JavaScript脚本对文本进行异或操作以达到对信息的加密</td>
</tr>
<tr>
<td width=50% height=5% >加密密码:<input name=key1 value=梅花雪疏影横斜></td>
<td width=50% height=5% >解密密码:<input name=key2 value=梅花雪疏影横斜></td>
</tr>
<tr>
<td height=45% ><textarea style="width:90%; height:94%" onblur="jia(this)"></textarea></td>
<td height=45% ><textarea style="width:90%; height:94%" onblur="jie(this)"></textarea></td>
</tr>
<tr>
<td height=45% ><textarea style="width:90%; height:94%" name=txtjia readonly>这里显示加密以后的结果</textarea></td>
<td height=45% ><textarea style="width:90%; height:94%" name=txtjie readonly>这里显示解密以后的结果</textarea></td>
</tr>
</table>

</body>
</html>

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧