Relaxlife.net可加密/解密中文/英文的Asp代码
发表于:2007-06-30来源:作者:点击数:
标签:
Relaxlife.net可加密/解密中文/英文的Asp代码供大家下载,这可是机密,可用在代码加密 可加密/解密中文/英文的Asp代码供大家下载,这可是机密,可用在代码加密 Function.asp % Rem================================================================= Rem=函数
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!@#$%^&*(),. ~`-=\?/’""fghjklzxc
vbnm<>;"
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="
clearcase/" target="_blank" >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//D
TD 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>
原文转自:http://www.ltesting.net