<% if request.Cookies("userid")<>"" then
Set DesCrypt = New Cls_DES
dim strKey
strKey=Second(time())&""&minute(time())&""&Second(time())&""&Second(time())*13&""&minute(time())*Second(time())*17&""&"ACE"&""&hour(now())*year(now())+1000&" FDEE"&"12"
strKey=left(strKey,14)&""
'response.Write(strKey)
dim strURLs
strURLs=""&strKey&"&"&request.Cookies("userid")&"&"&DesCrypt.DES(request.Cookies("userid"),strKey,0)&"&"&now()&"&"&request.ServerVariables("REMOTE_ADDR")
'response.Write(strURLs)
dim strURL
strURL=DesCrypt.DES(strURLs,"0EFc9A7BE44876",0)
'response.Write(strURL)
end if
%>index.asp 传值代码
Set DesCrypt = New Cls_DES
dim strKey
strKey=Second(time())&""&minute(time())&""&Second(time())&""&Second(time())*13&""&minute(time())*Second(time())*17&""&"ACE"&""&hour(now())*year(now())+1000&" FDEE"&"12"
strKey=left(strKey,14)&""
'response.Write(strKey)
dim strURLs
strURLs=""&strKey&"&"&request.Cookies("userid")&"&"&DesCrypt.DES(request.Cookies("userid"),strKey,0)&"&"&now()&"&"&request.ServerVariables("REMOTE_ADDR")
'response.Write(strURLs)
dim strURL
strURL=DesCrypt.DES(strURLs,"0EFc9A7BE44876",0)
'response.Write(strURL)
end if
%>index.asp 传值代码
解决方案 »
- Visual Studio 2010总是死,没反应,鼠标点击不能动了
- 在AJAX 使用CompanyValidator比较两次密码输入是否一致,结果错误消息一闪而过
- 急请高手帮忙:HttpRequest模拟自动登录,并获取此站某网页内容,OK就结贴。
- 谁帮帮我搞定paypal.com 的集成,不是paypal.com.cn 我愿意付费请老师,谢谢
- .net 服务器如何调用客户端函数
- 放过50分,无人问津——再放100分,现在要做一个计算机配件库存管理的程序,没有经验,想找一个这方面的源码程序参考一下!
- 在datagrid控件中,我令以行不可视,那么怎么读取这行的数据呢
- 开发ASP.net的软件?
- 用ASP.NET能否实现报表打印?
- 请问各位,net.core怎么查询数据并显示可以给一个实例吗?
- 见笑见笑 一个返回值的问题
- JQUERY高手进,使用jquery.get一个非常奇怪的问题!
Private IPRule, CPRule, EPRule, PRule, SBox(7), PCRule(1), MvRule
Private K(16), L(16), R(16)
Private FillCode, DesStatus
Private Sub Class_Initialize()
DesStatus = -1
FillCode = "0001101"
IPRule = "58,50,42,34,26,18,10,2," &_
"60,52,44,36,28,20,12,4," &_
"62,54,46,38,30,22,14,6," &_
"64,56,48,40,32,24,16,8," &_
"57,49,41,33,25,17, 9,1," &_
"59,51,43,35,27,19,11,3," &_
"61,53,45,37,29,21,13,5," &_
<!--。加密嘛,太多省略-->
Private Function KeyReverse()
Dim Temp, i
For i = 1 To 8
Temp = K(i)
K(i) = K(16 - i + 1)
K(16 - i + 1) = Temp
Next
End Function
Public Function DES(ByVal Data, ByVal Keys, ByVal Work)
Dim Text, i, Group, GroupLen
Text = Data
K(0) = HexToBinary(Keys)
If Work = 0 Then
Text = StrToBinary(Text)
Else
Text = HexToBinary(Text)
End If
GroupLen = Len(Text) \ 64 - 1
ReDim Group(GroupLen)
For i = 0 To GroupLen
Group(i) = Mid(Text, i * 64 + 1, 64)
Next
Text = ""
CreateKey()
For i = 0 To GroupLen
IP(Group(i))
If Work <> 0 And DesStatus <> 1 Then
KeyReverse()
DesStatus = 1
ElseIf Work = 0 And DesStatus = 1 Then
KeyReverse()
DesStatus = 0
End If
IterativeLR()
Text = Text & Permute(CPRule, R(16) & L(16))
Next
Erase Group
If Work = 0 Then
Text = BinaryToHex(Text)
Else
Text = BinaryToStr(Text)
End If DES = Text
End Function
End Class %>
<% function strToHex(strValue)
dim strTemp
dim i
strTemp=""
for i=1 to len(strValue & "")
strTemp=strTemp & hex(asc(mid(strValue,i,1)))
next
strToHex=strTemp
end function
strRes=request("key")
strKey=request("skey")
Set DesCrypt = New Cls_DES
if strRes<>"" and strKey<>"" then
strURL=DesCrypt.DES(strRes,strKey,1)
response.Write(strurl)
else
strKey=Second(time())&""&minute(time())&""&Second(time())&""&Second(time())*13&""&minute(time())*Second(time())*17&""&"ACE"&""&hour(now())*year(now())+1000&" FDEE"&"12"
strKey=left(strKey,14)&""
strURLs=""&strKey&"&"&now()&"&"&request.ServerVariables("REMOTE_ADDR")
response.Redirect("index.asp?URL="&DesCrypt.DES(strURLs,strKey,0))
end if
%>web_des.asp DES加密页
public class PageUrlz:System.Web.UI.Page
{
public PageUrlz()
{
if (!Page.IsPostBack)
{
HttpRequest req = Context.Request;
HttpResponse resp = Context.Response;
string strUrl = req.RawUrl;
if ((req.RawUrl.IndexOf('?') == -1 || req.RawUrl.IndexOf('?') == req.RawUrl.Length - 1) && strUrl.ToLower().IndexOf("downfile.aspx") == -1)
{
string strWebURL = "<font style=\"font-size:14px; color:#F00;\"color=\"red\" size=\"14px\">非法访问,5秒后转回首页</font><script>setTimeout(function(){window.location.href='index.asp';},5000);</script>";
resp.Write(strWebURL);
resp.End();
}
else //读取ASP页面取值
{
if (strUrl.ToLower().IndexOf("downfile.aspx") == -1)
{
strUrl = strUrl.Substring(strUrl.IndexOf('?') + 1);
string strURlR = "key=" + strUrl + "&skey=0EFc9A7BE44876";
string strUR = "http://192.168.0.1/web_des.asp";
string strHTML = "";
try
{
//resp.Write(strURlR);
//resp.Write(strUR);
strHTML = GreateWebRequest(strURlR, strUR);
}
catch
{
string strWebURLs = "<font style=\"font-size:14px; color:#F00;\"color=\"red\" size=\"14px\">非法访问,为了保证数据安全请从首页点击进入 5秒后转回首页 </font><script>setTimeout(function(){window.location.href='index.asp';},5000);</script>";
resp.Write(strWebURLs);
resp.End();
}
string[] strs = strHTML.Replace("<html>", "").Replace("\r", "").Replace("\n", "").Replace("</body></html>", "").Split('&');
string strIP = Context.Request.ServerVariables["REMOTE_ADDR"];
if (strIP == null)
{
strIP = "";
} if (strIP.Trim() != strs[4].Trim())
{
string strWebURLs = "<font style=\"font-size:14px; color:#F00;\"color=\"red\" size=\"14px\">非法访问,为了保证数据安全请从首页点击进入 5秒后转回首页 </font><script>setTimeout(function(){window.location.href='index.asp';},5000);</script>";
resp.Write(strWebURLs);
resp.End();
}
else if (Convert.ToDateTime(strs[3]).AddHours(0.3) < DateTime.Now)
{
string strWebURLs = "<font style=\"font-size:14px; color:#F00;\"color=\"red\" size=\"14px\">你可能长时间没有操作,为了保证数据安全5秒后转回首页!<BR>请您重新登入并浏览 </font><script>setTimeout(function(){window.location.href='index.asp';},5000);</script>";
resp.Write(strWebURLs);
resp.End();
}
else
{
string strURlRs = "key=" + strs[2] + "&skey=" + strs[0];
string strWe = "";
try
{
strWe = GreateWebRequest(strURlRs, strUR).Replace("<html>", "").Replace("\r", "").Replace("\n", "").Replace("</body></html>", "");
}
catch
{
string strWebURLs = "<font style=\"font-size:14px; color:#F00;\"color=\"red\" size=\"14px\">非法访问,5秒后转回首页</font><script>setTimeout(function(){window.location.href='index.asp';},5000);</script>";
resp.Write(strWebURLs);
resp.End();
}
//resp.Write(strWe);
if (strWe != strs[1])
{
string strWebURLs = "<font style=\"font-size:14px; color:#F00;\"color=\"red\" size=\"14px\">非法访问,5秒后转回首页</font><script>setTimeout(function(){window.location.href='index.asp';},5000);</script>";
resp.Write(strWebURLs); resp.End();
}
}
}
}
}
}
public string GreateWebRequest(string strPu, string strURL)
{
HttpRequest req = Context.Request;
HttpResponse resp = Context.Response;
string strURlR = strPu;// "key=" + strUrl + "&skey=0EFc9A7BE44876";
byte[] by = System.Text.Encoding.GetEncoding("Gb2312").GetBytes(strURlR);
string strWebURL = strURL;
HttpWebRequest hwrt = (HttpWebRequest)WebRequest.Create(strWebURL);
//resp.Write(strURlR+"<br>");
hwrt.Method = "Post";
hwrt.ContentType = "application/x-www-form-urlencoded";
hwrt.ContentLength = by.Length;
hwrt.KeepAlive = false;
hwrt.ProtocolVersion = HttpVersion.Version10;
Stream str = hwrt.GetRequestStream();
str.Write(by, 0, by.Length);
str.Flush();
str.Close();
HttpWebResponse hwrp = (HttpWebResponse)hwrt.GetResponse();
StreamReader srrd = new StreamReader(hwrp.GetResponseStream(), System.Text.Encoding.GetEncoding("GB2312"));
string strHTML = srrd.ReadToEnd();
//resp.Write(strHTML);
//resp.End();
return strHTML;
}
}PageUrlz.cs .NET子页显示首页传入的值
这个是2个页面传值,其中用web_des页过度一下,但是现在出现了一个问题就是传值后PageUrlz.cs页得strHTML取到的值会是乱码|U1zn# dT HzjjZX>mW:X([}/&_rPn6ZzRew:#=vM 2
小弟弄了很长时间,但是也没什么头绪,请高手们看一看啊
string GreateWebRequest(string strPu, string strURL)
{
HttpRequest req = Context.Request;
HttpResponse resp = Context.Response;
string strURlR = strPu;// "key=" + strUrl + "&skey=0EFc9A7BE44876";
byte[] by = System.Text.Encoding.GetEncoding("Gb2312").GetBytes
public string GreateWebRequest(string strPu, string strURL)
{
HttpRequest req = Context.Request;
HttpResponse resp = Context.Response;
string strURlR = strPu;// "key=" + strUrl + "&skey=0EFc9A7BE44876";
// byte[] by = System.Text.Encoding.GetEncoding("Gb2312").GetBytes(strURlR);
byte[] by = System.Text.Encoding.Default.GetBytes(strURlR);
string strWebURL = strURL;
HttpWebRequest hwrt = (HttpWebRequest)WebRequest.Create(strWebURL);
//resp.Write(strURlR+"<br>");
hwrt.Method = "Post";
hwrt.ContentType = "application/x-www-form-urlencoded";
hwrt.ContentLength = by.Length;
hwrt.KeepAlive = false;
hwrt.ProtocolVersion = HttpVersion.Version10;
Stream str = hwrt.GetRequestStream();
str.Write(by, 0, by.Length);
str.Flush();
str.Close();
HttpWebResponse hwrp = (HttpWebResponse)hwrt.GetResponse();
//StreamReader srrd = new StreamReader(hwrp.GetResponseStream(), System.Text.Encoding.GetEncoding("GB2312"));
StreamReader srrd = new StreamReader(hwrp.GetResponseStream(), System.Text.Encoding.Default);
string strHTML = srrd.ReadToEnd();
resp.Write(strHTML);
//resp.End();
return strHTML;
}改后依然乱码
*!~n6vc{
System.Text.Encoding.GetEncoding("Gb2312").GetBytes(strURlR);
也看不出有什么效果,望高手们分析一下后给出个解决方法。。
依然还是不行,直接输出ASCII好像不行。
只有取到正常明文值才可以显示出来。
//resp.Write(strURlR+"<br>");
hwrt.Method = "Post";
hwrt.ContentType = "application/x-www-form-urlencoded";
hwrt.ContentLength = by.Length;
hwrt.KeepAlive = false;
hwrt.ProtocolVersion = HttpVersion.Version10;
Stream str = hwrt.GetRequestStream();
str.Write(by, 0, by.Length);
str.Flush();
str.Close();
HttpWebResponse hwrp = (HttpWebResponse)hwrt.GetResponse();
StreamReader srrd = new StreamReader(hwrp.GetResponseStream(), System.Text.Encoding.GetEncoding("GB2312"));
string strHTML = srrd.ReadToEnd();
使用 UTF-8 编码试试
嗯,最早我就先实验的UTF-8,但是可惜还是不好用,我怀疑可能是
string strUR = "http://192.168.0.1/web_des.asp";
页传过来时的问题,在web_des.asp时就已经做了一次
response.Redirect("index.asp?URL="&DesCrypt.DES(strURLs,strKey,0))
编码,乱成那样有没有可能是这个东西给搞的呢?
resp.Write(System.Text.Encoding.GetEncoding("GB2312").GetBytes(strHTML));
然后输出了
System.Byte[]