I have the vba excel function convert my string text to hash.
Private Function HashString(inputText As String, Optional secretKey = "") As String
Dim asc As Object
Dim enc As Object
Dim textToHash() As Byte
Dim SharedSecretKey() As Byte
Dim bytes() As Byte
If secretKey = "" Then secretKey = inputText
Set asc = CreateObject("System.Text.UTF8Encoding")
Set enc = CreateObject("System.Security.Cryptography.HMACSHA1")
textToHash = asc.GetBytes_4(inputText)
SharedSecretKey = asc.GetBytes_4(secretKey)
enc.Key = SharedSecretKey
bytes = enc.ComputeHash_2((textToHash))
HashString = EncodeBase64(bytes)
End Function
Private Function EncodeBase64(arrData() As Byte) As String
Dim objXML As Object
Dim objNode As Object
Set objXML = CreateObject("MSXML2.DOMDocument")
Set objNode = objXML.createElement("b64")
objNode.DataType = "bin.base64"
objNode.nodeTypedValue = arrData
EncodeBase64 = objNode.Text
End Function
I want to use this function on other C# platforms to have the same algorithm output, How to convert this method to C#? Thanks for the help.
thanks Tim Williams. Answer link
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.