<%
Function HEX_to_BIN(Hex)
Dim i,B
Hex=UCase(Hex)
For i=1 To Len(Hex)
Select Case Mid(Hex,i,1)
Case “0”: B=B&”0000″
Case “1”: B=B&”0001″
Case “2”: B=B&”0010″
Case “3”: B=B&”0011″
Case “4”: B=B&”0100″
Case “5”: B=B&”0101″
Case “6”: B=B&”0110″
Case “7”: B=B&”0111″
Case “8”: B=B&”1000″
Case “9”: B=B&”1001″
Case “A”: B=B&”1010″
Case “B”: B=B&”1011″
Case “C”: B=B&”1100″
Case “D”: B=B&”1101″
Case “E”: B=B&”1110″
Case “F”: B=B&”1111″
End Select
Next
HEX_to_BIN=B
End Function
Function BIN_to_HEX(Bin)
Dim i,H
If Len(Bin) Mod 4<>0 Then
Bin=String(4-Len(Bin) Mod 4,”0″)&Bin
End If
For i=0 To Len(Bin)/4
Select Case Mid(Bin,i*4+1,4)
Case “0000”: H=H&”0″
Case “0001”: H=H&”1″
Case “0010”: H=H&”2″
Case “0011”: H=H&”3″
Case “0100”: H=H&”4″
Case “0101”: H=H&”5″
Case “0110”: H=H&”6″
Case “0111”: H=H&”7″
Case “1000”: H=H&”8″
Case “1001”: H=H&”9″
Case “1010”: H=H&”A”
Case “1011”: H=H&”B”
Case “1100”: H=H&”C”
Case “1101”: H=H&”D”
Case “1110”: H=H&”E”
Case “1111”: H=H&”F”
End Select
Next
BIN_to_HEX=H
End Function
Function BinVal(bin)
Dim ret
ret=0
For i=LenB(bin) To 1 step-1
ret=ret*256+AscB(MidB(bin,i,1))
Next
BinVal=ret
End Function
Function ReadBinFile_H(fileName,HZs)
Dim objStream,bFlag,HZK16_Hs,HZ16,m,n
HZK16_Hs=”<p>横向:</p>”
Set objStream=Server.CreateObject(“ADODB.Stream”)
objStream.Open
objStream.Type=1
objStream.LoadFromFile fileName
For m=1 To Len(HZs)
HZ=Mid(HZs,m,1)
HZK16_Hs=HZK16_Hs&HZ&”:<br />”
objStream.Position=0
HZ16=Hex(Asc(HZ))
objStream.Read((94*(CLng(“&H”&Mid(HZ16,1,2))-&HA1)+(CLng(“&H”&Mid(HZ16,3,2))-&HA1))*32)
For n=1 To 32
bFlag=objStream.Read(1)
If BinVal(bFlag)<=15 Then
HZK16_Hs=HZK16_Hs&”0″& Hex(BinVal(bFlag))
Else
HZK16_Hs=HZK16_Hs& Hex(BinVal(bFlag))
End If
Next
HZK16_Hs=HZK16_Hs&”<br />”
Next
objStream.Close
ReadBinFile_H=HZK16_Hs
End Function
Function ReadBinFile_S(fileName,HZs)
Dim objStream,bFlag,HZK16_Hs,HZ16,m,n
HZK16_Hs=””
Set objStream=Server.CreateObject(“ADODB.Stream”)
objStream.Open
objStream.Type=1
objStream.LoadFromFile fileName
For m=1 To Len(HZs)
HZ=Mid(HZs,m,1)
objStream.Position=0
HZ16=Hex(Asc(HZ))
objStream.Read((94*(CLng(“&H”&Mid(HZ16,1,2))-&HA1)+(CLng(“&H”&Mid(HZ16,3,2))-&HA1))*32)
For n=1 To 32
bFlag=objStream.Read(1)
If BinVal(bFlag)<=15 Then
HZK16_Hs=HZK16_Hs&”0″& Hex(BinVal(bFlag))
Else
HZK16_Hs=HZK16_Hs& Hex(BinVal(bFlag))
End If
Next
Next
objStream.Close
Dim HZK16_Ss,i,x,y,HZK2_H,HZK16(16,16),HZK2_S
HZK16_Ss=”<p>竖向:</p>”
For i=0 To Len(HZK16_Hs)/64-1
HZK16_H=Mid(HZK16_Hs,i*64+1,64)
For x=0 To Len(HZK16_H)/4-1
HZK2_H=HEX_to_BIN(Mid(HZK16_H,x*4+1,4))
For y=0 To Len(HZK2_H)-1
HZK16(x,y)=Mid(HZK2_H,y+1,1)
Next
Next
x=0
y=0
HZK2_S=””
For x=0 To 15
For y=0 To 15
HZK2_S=HZK2_S&HZK16(y,x)
Next
Next
HZK16_Ss=HZK16_Ss&Mid(HZs,i+1,1)&”:<br />”&BIN_to_HEX(HZK2_S)&”<br />”
Next
ReadBinFile_S=HZK16_Ss
End Function
Dim HexStr_H,HexStr_S
HexStr_H=ReadBinFile_H(“HZK16文件绝对路径”,”王国强”)
Response.Write HexStr_H
HexStr_S=ReadBinFile_S(“HZK16文件绝对路径”,”王国强”)
Response.Write HexStr_S
%>
转载于:https://blog.51cto.com/332374363/972896
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/110337.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...