存档

2009年1月2日 的存档

       最近,朋友要给他的客户与客户交流,涉及一些很重要的信息,通过QQ,MSN感觉很不可靠,于是请我写一个加密解密工具,防止信息在中途被截取。
      解密工具直接交给客户,而交流信息通过E-mail或QQ。汗,我等小鸟怎么会那种高深的东东,实在是。。。为了朋友,赴刀山,下火海,奋斗了一个晚上,终于写出来了一个。好东西不敢分享,发出来共享给大家,高手见笑了。
    原文地址为:http://miaoqiyuan.cn/p/javascript-jiami
    因为朋友特别说是很重要的信息,我想到了以前学C的时候有一个把每个字符的编码读取出来加13的一个算法。正巧Javascript中有一个charCodeAt,呵呵,把要加密的内容,依次对出每个字符的字符编码,然后做一些处理,嘎嘎。。。。只要不知道算法,还是很难破解出来的,呵呵。
    具体算法还是大家自己看吧,说出来就没有意思了。本文的算法与给朋友的稍微有些差别,毕竟安全第一。下面是运行界面,还是使用了我喜欢的hta文件。代码全是Javascript。

测试地址:
加密:http://www.miaoqiyuan.cn/products/js-jiami.htm
解密:http://www.miaoqiyuan.cn/products/js-jiemi.htm
加密.hta代码(完全可以保存为html,执行效果一样)

< !DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>设置加密邮件内容</title>
<script type="text/javascript">
function itArt(){
this.html="Hello";
this.css="color:#000;width:640px;text-indent:20px;padding:5px;border:solid 5px #666;margin:5px;background:#CCC;margin-left:auto;margin-right:auto";
this.length=0;
}
 
itArt.prototype = {
init:function(){
this.length=this.html.length;
},
play:function(){
this.init();
this.setPassword();
this.echo();
},
setHtml:function(v){
this.html=v;
},
setPassword:function(){
var tmp="";
for(var i=0;i<this .length;i++){
tmp+="$"+this.html.charCodeAt(i);
}
this.html=tmp;
tmp="";
for(var i=0;i<this.html.length;i+=3){
tmp+=" "+this.html.substr(i,3);
}
this.html=tmp;
tmp="";
for(var i=0;i<this.html.length;i++){
tmp+=" "+this.html.charCodeAt(i);
}
this.html=tmp;
},
echo:function(){
var t=document.createElement("div");
t.innerHTML=this.html;
if(window.ActiveXObject)
t.style.cssText=this.css;
else
t.setAttribute("style",this.css);
//不想用DOM删掉子元素了,反正各浏览器都支持
document.getElementById("x100").innerHTML="";
document.getElementById("x100").appendChild(t);
}
}
function setPassword(t){
if(t!=""){
var demo=new itArt();
demo.setHtml(t);
demo.play();
}else{
alert("请输入内容开始加密");
}
}
window.onload=function(){
setPassword("你好,猜猜我给你的密文是什么? 哈哈,猜不到吧");
}
</script>
</this></script></head>
<body>
<textarea style="display:block;color:#000;width:640px;height:280px;text-indent:20px;border:solid 5px #666;margin:5px;background:#FFF;margin-left:auto;margin-right:auto" ondblclick="setPassword(this.value);" title="双击开始加密">你好,猜猜我给你的密文是什么? 哈哈,猜不到吧</textarea>
<div id="x100">
</div>
</body>

解密.hta代码

< !DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>获取加密邮件内容</title>
<script type="text/javascript">
function itArt(){
this.html="Hello";
this.css="color:#000;width:640px;text-indent:20px;padding:5px;border:solid 5px #666;margin:5px;background:#CCC;margin-left:auto;margin-right:auto";
this.length=0;
}
 
itArt.prototype [...]

一 2nd, 2009 | Filed under Javascript