File: D:/web/hyperflight/! bs3/hmac-hash-test.asp
<%Option Explicit%>
<html>
<head>
</head>
<body>
<h1>GetHMACSHA256Base64 Test</h1>
<%
Dim LText, LKey, LResult
LText = "Just testing"
LKey = "Secret key"
Response.Write "LText: " & LText & "<br>"
Response.Write "LKey: " & LKey & "<br>"
LResult = GetHMACSHA256Base64(LText, LKey)
Response.Write "LResult: " & LResult & "<br>"
Response.Write "<br>"
%>
</body>
</html>
<%
' (SS,10/6/22) with help from
' https://github.com/as08/ClassicASP.PasswordHashing
' https://github.com/as08/ClassicASP.PasswordHashing/blob/master/Crypto.Class.asp
' https://www.excelhowto.com/macros/excel-vba-base64-hmac-sha256-and-sha1-encryption/
Function GetHMACSHA256Base64(ByVal ATextToHash, ByVal ASecretKey)
Dim LoHMACSHA256, LoUTF8, LoEncode
Set LoHMACSHA256 = CreateObject("System.Security.Cryptography.HMACSHA256")
Set LoUTF8 = CreateObject("System.Text.UTF8Encoding")
Set LoEncode = CreateObject("MSXML2.DomDocument").CreateElement("encode")
LoHMACSHA256.Key = LoUTF8.GetBytes_4(ASecretKey)
LoEncode.DataType = "bin.base64"
LoEncode.nodeTypedValue = LoHMACSHA256.ComputeHash_2(LoUTF8.GetBytes_4(ATextToHash))
GetHMACSHA256Base64 = LoEncode.Text
Set LoHMACSHA256 = Nothing
Set LoUTF8 = Nothing
Set LoEncode = Nothing
End Function
%>