这行Digest = htactx.HTSHA1("<%=Session["Message"].ToString()%>",<%=lRndLen%>)'SHA1数据
总是说:当前上下文中不存在名称“lRndLen”
<%@ Page Language="c#" EnableSessionState="true" %><%
Random randomGenerator = new Random(DateTime.Now.Millisecond); String RandData = "";
int lRndLen = 0;
for (int i = 0; i < 15; i++)
RandData += Convert.ToChar(randomGenerator.Next(97, 122));
Session["Message"] = RandData;
lRndLen = RandData.Length;
%>
<html>
<head runat=server>
<title>Logon - HaiKey ActiveX Test [ASP.NET]</title>
<%--<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
--%><%--<style type="text/css">
<!--
@import "test.css";
-->
</style>--%>
<script language="VBScript">
Dim FirstDigest
Dim Digest
Digest= "01234567890123456"dim bErrsub ShowErr(Msg)
bErr = true
MsgBox Msg
' Document.Writeln "<FONT COLOR='#FF0000'>"
' Document.Writeln "<P> </P><P> </P><P> </P><P ALIGN='CENTER'><B>ERROR:</B>"
' Document.Writeln "<P> </P><P ALIGN='CENTER'>"
' Document.Writeln Msg
' Document.Writeln " failed, and returns 0x" & hex(Err.number) & ".<br>"
' Document.Writeln "<P> </P><P> </P><P> </P>"
' Document.Writeln "</FONT>"
End Subfunction Validate()
Digest = "01234567890123456"
On Error Resume Next
Dim TheForm
Set TheForm = Document.forms("ValidForm")
If Len(TheForm.UserPIN.Value) < 4 Then
MsgBox "PIN empty or user pin length less than 4 or so pin length less than 6!!"
Validate = FALSE
Exit Function
End If bErr = false 'Let detecte whether the haikey Safe Active Control loaded.
'If we call any method and the Err.number be set to &H1B6, it
'means the hakey Safe Active Control had not be loaded.
dim LibVer
LibVer = htactx.GetLibVersion
If Err.number <> 0 Then ShowErr "Load haikey Safe Active Control"
Validate = false
Exit function
Else
dim hCard
hCard = 0
hCard = htactx.OpenDevice(1)'打开设备
If Err.number<>0 or hCard = 0 then
ShowErr "Open first haikey failed."
Validate = false
Exit function
End if
htactx.VerifyUserPin hCard, CStr(TheForm.UserPIN.Value)'校验口令
If Err.number<>0 Then
ShowErr "Verify User PIN Failure!!!"
Validate = false
htactx.CloseDevice hCard
Exit function
End If
dim UserName
UserName = htactx.GetUserName(hCard)'获取用户名
If Err.number<>0 Then
ShowErr "Get User Name Failure!!!"
Validate = false
htactx.CloseDevice hCard
Exit function
End If
Digest = htactx.HTSHA1("<%=Session["Message"].ToString()%>",<%=lRndLen%>)'SHA1数据 If Err.number<>0 Then
ShowErr "SHA1 failed."
Validate = false
htactx.CloseDevice hCard
Exit function
End If Digest = Digest&"04040404"'对SHA1数据进行补码
EnData = htactx.HTCrypt(hCard,0 ,0,Digest, len(Digest))'DES3加密SHA1后的数据
If Err.number<>0 Then
ShowErr "HashToken compute"
Validate = false
htactx.CloseDevice hCard
Exit function
End If
htactx.CloseDevice hCard
DigestID.innerHTML = "<input type='hidden' name='EncData' Value='" & EnData & "'>"
snID.innerHTML = "<input type='hidden' name='UserID' Value='" & UserName & "'>"
End If
End function
</script><script language="VBScript">
function ChangUserPIN()
On Error Resume next
Dim ChangeForm
Set ChangeForm = Document.forms("ValidForm") If (ChangeForm.NewPIN.value) = (ChangeForm.AffirmPIN.value) Then
MsgBox "两次输入的新PIN码一至!"
else
MsgBox "两次输入的新PIN码不一至"
htactx.CloseDevice hCard
Exit function
End if
Dim LibVer
LibVer = htactx.GetLibVersion
If Err.number <> 0 Then
MsgBox "加载客户端控件失败"
Exit function
End If
'MsgBox "加载客户端控件成功!"
Dim hCard
hCard = 0
hCard = htactx.OpenDevice(1)'打开设备
If Err.number<>0 or hCard = 0 Then
MsgBox "打开硬件锁失败!"
Exit function
End If
'MsgBox "打开硬件锁成功!"
htactx.VerifyUserPin hCard, CStr(ChangeForm.OldPIN.Value)'校验口令
If Err.number<>0 Then
MsgBox "PIN码验证失败!"
htactx.CloseDevice hCard
Exit function
End If
'MsgBox "PIN码验证成功!" '改PIN码
htactx.ChangeUserPin hCard, CStr(ChangeForm.OldPIN.value), CStr(ChangeForm.NewPIN.value)
If Err.number<>0 Then
MsgBox "修改PIN码失败!"
htactx.CloseDevice hCard
Exit function
End If
MsgBox "修改PIN码成功"
htactx.CloseDevice hCard
'MsgBox "关闭硬件锁成功!"End function
</script></head>
<body>
<object id="htactx" name="htactx"
classid="clsid:FB4EE423-43A4-4AA9-BDE9-4335A6D3C74E" codebase="HTActX.cab#version=1,0,0,1" style="HEIGHT: 0px; WIDTH: 0px"></object>
<input id="Hidden1" type="hidden" />
<table width="600" border="0" style="text-align: center">
<tr>
<td>
<p style="text-align: center"></p>
<script id="clientEventHandlersVBS" language="vbscript"> Document.Writeln "<FORM id=ValidForm METHOD='post' ACTION='verify.aspx' onsubmit='return Validate();' language='jscript' ALIGN='center'>"
Document.Writeln "<span id=DigestID></span>"
Document.Writeln "<span id=snID></span>"
Document.Writeln "<TABLE BORDER='0' ALIGN='center' CELLSPACING='0' BORDERCOLORDARK='#E7EBFF' BORDERCOLORLIGHT='#000000' style='height:188px; width: 518px; background-color: #3366cc;'>"
Document.Writeln "<TR ALIGN='center' ><TD><font color='white'>用户密码:</font><INPUT TYPE='password' NAME='UserPIN' CLASS='inputtext'></TD></TR>"
Document.Writeln "<TR ALIGN='center' ><TD><INPUT TYPE='submit' NAME='Submit' VALUE='登录' CLASS='inputbtn' style='height: 23px; width: 85px;'> <INPUT TYPE='reset' NAME='Reset' VALUE='重置' CLASS='inputbtn' style='height: 23px; width: 85px;'></TD></TR>"
Document.Writeln "</table>"</script> </td>
</tr>
</table>
</body>
</html>
然后就报:分析器错误信息: 未能加载类型“TeamLong.SBSM.WebUI.Logon”。