relaxlife.net可加密/解密中文/英文的asp代码供大家下载,这可是机密,可用在代码加密
可加密/解密中文/英文的asp代码供大家下载,这可是机密,可用在代码加密
function.asp
<%
rem =================================================================
rem = 函数文件:function.asp
rem = 测试文件:testencrypt.asp,encryptpass.asp
rem = 说明:encrypt_pro加密函数,decrypt_pro解密函数
rem = revision:1.01 beta
rem = 作者:熊氏英雄(cexo255),小奎
rem = date:2005/04/20 03:41:10
rem = qq:30133499,38377160
rem = mysite:http://www.relaxlife.net
rem = qq群:4341998
rem = 适用:对数据的加密,或对代码的加密,可加密中文/英文等。完全解密,不会出现解密出现乱码。
rem = 下版本预计改进:代码算法需要重写,可能知道的人多了就不太安全了。
rem =================================================================
public const sdefaultwheel1 = “abcdefghijklmnopqrstvuwxyz_1234567890qwertyuiopasd!@#$%^&*(),. ~`-=\?/’””fghjklzxcvbnm<>;”
public const sdefaultwheel2 = “iwehjktlzvopfg_1234567890qwerbnmqryuasdxcfghjklzxc ~`-=\?/’””!@#$%^&*(),.vbnm<>;tyuiopasd”
function encrypt_pro(sinput , spassword )
dim swheel1, swheel2
dim k, c, i
dim sresult
swheel1 = sdefaultwheel1: swheel2 = sdefaultwheel2
scramblewheels swheel1, swheel2, spassword
sresult = “”
for i = 1 to len(sinput)
c = mid(sinput, i, 1)
k = instr(1, swheel1, c)
if k > 0 then
sresult = sresult & mid(swheel2, k, 1)
else
sresult = sresult & addpass(c,spassword)
end if
swheel1 = leftshift(swheel1): swheel2 = rightshift(swheel2)
next
encrypt_pro = sresult
end function
function decrypt_pro(sinput , spassword )
dim swheel1, swheel2
dim k, i, c
dim sresult
swheel1 = sdefaultwheel1: swheel2 = sdefaultwheel2
scramblewheels swheel1, swheel2, spassword
sresult = “”
for i = 1 to len(sinput)
c = mid(sinput, i, 1)
k = instr(1, swheel2, c, vbbinarycompare)
if k > 0 then
sresult = sresult & mid(swheel1, k, 1)
else
sresult = sresult & addpass(c,spassword)
end if
swheel1 = leftshift(swheel1): swheel2 = rightshift(swheel2)
next
decrypt_pro = sresult
end function
function leftshift(s )
if len(s) > 0 then leftshift = mid(s, 2, len(s) – 1) & mid(s, 1, 1)
end function
function rightshift(s )
if len(s) > 0 then rightshift = mid(s, len(s), 1) & mid(s, 1, len(s) – 1)
end function
sub scramblewheels(byref sw1 , byref sw2 , spassword )
dim i ,k
for i = 1 to len(spassword)
for k = 1 to asc(mid(spassword, i, 1)) * i
sw1 = leftshift(sw1): sw2 = rightshift(sw2)
next
next
end sub
function addpass(tstr,tpass)
select case tstr
case chr(13)
addpass = tstr
case chr(10)
addpass = tstr
case chr(13)+chr(10)
addpass = tstr
case chr(9)
addpass = tstr
case else
addpass = chr((asc(tpass) xor len(tpass)) xor asc(tstr))
end select
end function
function readfile(filename)
dim fso, f
const forreading = 1, forwriting = 2, forappending = 8
set fso = createobject(“scripting.filesystemobject”)
set f = fso.opentextfile(server.mappath(filename), forreading, true)
readfile = f.readall
f.close
end function
sub writefile(filename,str)
dim fso, f
const forreading = 1, forwriting = 2, forappending = 8
set fso = createobject(“scripting.filesystemobject”)
set f = fso.opentextfile(server.mappath(filename), forwriting, true)
f.write str
f.close
end sub
%>
————————–加密代码的使用方法———————–
从文件index_buk.htm中读加密后写到index.htm文件中然后解密并显示
也是所谓的asp代码与html代码分离。
index_buk.htm代码为:
<html>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=gb2312″>
<title>放松生活</title>
<meta name=”description” content=”放松生活,放松,生活,轻松生活,笑话,小品,小故事,智力赛,搞笑,图片,精品,flash,短片,影片,经典影片,经典,下载,文档下载,经典代码下载,经典广告,情感,源代码,,,”>
<meta name=”keywords” content=”放松生活,放松,生活,轻松生活,笑话,小品,小故事,智力赛,搞笑,图片,精品,flash,短片,影片,经典影片,经典,下载,文档下载,经典代码下载,经典广告,情感,源代码,,,”>
<meta name=”author” content=”relaxlife”>
<meta name=”robots” content=”all”>
<link href=”css/css.css” rel=”stylesheet” type=”text/css”>
<style type=”text/css”>
<!–
.style1 {
color: #990000;
font-weight: bold;
}
–>
</style>
<body>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<table width=”500″ border=”0″ align=”center” cellpadding=”3″ cellspacing=”1″ bgcolor=”cccccc”>
<tr align=”center” bgcolor=”#efefef”>
<td colspan=”2″><span class=”style1″>系统发生错误!</span></td>
</tr>
<tr bgcolor=”ffffff”>
<td colspan=”2″>{$msgcon$}</td>
</tr>
<tr bgcolor=”ffffff”>
<td colspan=”2″ align=”center”><< <a href=”javascript:history.go(-1);”>返回重新操作</a> >></td>
</tr>
</table>
<p align=”center”> </p>
</body>
</html>
——————————————asp代码调用:
<!–#include file=”function.asp” –>
<%
rem =================================================================
rem = 函数文件:function.asp
rem = 测试文件:testencrypt.asp,encryptpass.asp
rem = 说明:encrypt_pro加密函数,decrypt_pro解密函数
rem = revision:1.01 beta
rem = 作者:熊氏英雄(cexo255),小奎
rem = date:2005/04/20 03:41:10
rem = qq:30133499,38377160
rem = mysite:http://www.relaxlife.net
rem = qq群:4341998
rem = 适用:对数据的加密,或对代码的加密,可加密中文/英文等。完全解密,不会出现解密出现乱码。
rem = 下版本预计改进:代码算法需要重写,可能知道的人多了就不太安全了。
rem =================================================================
str = readfile(“index_buk.htm”)
pass = “cexo”
encrypt_str = encrypt_pro(str,pass)
decrypt_str = decrypt_pro(encrypt_str,pass)
response.write encrypt_str
writefile “index.htm”,encrypt_str
response.write decrypt_str
str2 = readfile(“index.htm”)
decrypt_str = decrypt_pro(str2,pass)
str3 = “<li>1111111111111111111111111111</li><br><li>1111111111111111111111111111</li><br><li>22222222222222222222222222222</li><br><li>33333333333333333333333333</li><br>”
msg = replace(decrypt_str,”{$msgcon$}”,str3)
response.write msg
%>
————————–加密数据的使用方法———————–
<%
rem =================================================================
rem = 函数文件:function.asp
rem = 测试文件:testencrypt.asp,encryptpass.asp
rem = 说明:encrypt_pro加密函数,decrypt_pro解密函数
rem = revision:1.01 beta
rem = 作者:熊氏英雄(cexo255),小奎
rem = date:2005/04/20 03:41:10
rem = qq:30133499,38377160
rem = mysite:http://www.relaxlife.net
rem = qq群:4341998
rem = 适用:对数据的加密,或对代码的加密,可加密中文/英文等。完全解密,不会出现解密出现乱码。
rem = 下版本预计改进:代码算法需要重写,可能知道的人多了就不太安全了。
rem =================================================================
%>
<!–#include file=”function.asp” –>
<!doctype html public “-//w3c//dtd html 4.01 transitional//en” “http://www.w3.org/tr/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=gb2312″>
<title>加密解密实例</title>
</head>
<body>
<%
pass = request(“txtpass”)
if pass = null then pass = “”
%>
<form name=”form1″ method=”post” action=”testencrypt.asp”>
请输入要加密的文本:<br>
<textarea name=”txt1″ cols=”80″ rows=”10″><%=server.htmlencode(decrypt_pro(request(“txt2”),pass))%></textarea>
<br>
求得解密文本为: 密码为:
<input name=”txtpass” type=”text” id=”txtpass” value=”<%=pass%>”>
<br>
<textarea name=”txt2″ cols=”80″ rows=”10″><%=encrypt_pro(request(“txt1”),pass)%></textarea>
<br><input type=”submit” name=”submit” value=”加密”>
<input type=”submit” name=”submit2″ value=”解密”>
</form>
</body>
</html>