|
- <%
- Response.Write SHA512("ttasp" , False)
- Public Function SHA512(sIn , bB64)
-
- '128 Hex: cf83e1357eefb8bd...etc
- '88 Base-64: z4PhNX7vuL3xVChQ...etc
-
- Dim oT , oSHA512
- Dim TextToHash, bytes
-
- Set oT = CreateObject("System.Text.UTF8Encoding")
- Set oSHA512 = CreateObject("System.Security.Cryptography.SHA512Managed")
-
- TextToHash = oT.GetBytes_4(sIn)
- bytes = oSHA512.ComputeHash_2((TextToHash))
-
- If bB64 = True Then
- SHA512 = ConvToBase64String(bytes)
- Else
- SHA512 = ConvToHexString(bytes)
- End If
-
- Set oT = Nothing
- Set oSHA512 = Nothing
-
- End Function
- Private Function ConvToBase64String(vIn)
- Dim oD
- Set oD = CreateObject("MSXML2.DOMDocument")
- With oD
- .LoadXML "<root />"
- .DocumentElement.DataType = "bin.base64"
- .DocumentElement.nodeTypedValue = vIn
- End With
- ConvToBase64String = Replace(oD.DocumentElement.text, vbLf, "")
-
- Set oD = Nothing
- End Function
- Private Function ConvToHexString(vIn )
- Dim oD
- Set oD = CreateObject("MSXML2.DOMDocument")
- With oD
- .LoadXML "<root />"
- .DocumentElement.DataType = "bin.Hex"
- .DocumentElement.nodeTypedValue = vIn
- End With
- ConvToHexString = Replace(oD.DocumentElement.text, vbLf, "")
-
- Set oD = Nothing
- End Function
- %>
复制代码 |
|