<%
|
Function sha1(instr)
|
Dim asc, enc, bytes, outstr, pos
|
'Borrow some objects from .NET (supported from 1.1 onwards)
|
Set asc = Server.CreateObject("System.Text.UTF8Encoding")
|
Set enc = Server.CreateObject( _
|
"System.Security.Cryptography.SHA1CryptoServiceProvider")
|
|
'Convert the string to a byte array and hash it
|
bytes = asc.GetBytes_4(instr)
|
bytes = enc.ComputeHash_2((bytes))
|
|
outstr = ""
|
|
'Convert the byte array to a hex string
|
For pos = 1 To Lenb(bytes)
|
outstr = outstr & LCase(Right("0" & Hex(Ascb(Midb(bytes, pos, 1))), 2))
|
Next
|
sha1 = outstr
|
Set enc = Nothing
|
Set asc = Nothing
|
End Function
|
%>
|