求可逆加密方法

上海程序员3 2006-02-14 01:03:59
加密内容不会太多,安全性也不必太高,但希望能可逆的,更希望简单,效率高些,但光看加密后的东西是看不出什么来的就够了。
...全文
198 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
meizz 2006-02-15
  • 打赏
  • 举报
回复
异或操作:

<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>
上海程序员3 2006-02-15
  • 打赏
  • 举报
回复
base64方法不错,但加密后的内容是一致的,也就是说谁看了这个用base64解密试试就能试出来了!
rightyeah 2006-02-15
  • 打赏
  • 举报
回复
escape unescape不行的,它们对普通的字母数字是不进行处理的
KimSoft 2006-02-14
  • 打赏
  • 举报
回复
javascript内置的escape unescape就很不错
mrshelly 2006-02-14
  • 打赏
  • 举报
回复
base64
mingxuan3000 2006-02-14
  • 打赏
  • 举报
回复
escape()
unescape()

87,921

社区成员

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

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