I have implemented the hash method as suggested on the post:
This is my implementation:
Public Function BASE64SHA1(ByVal sTextToHash As String)
Dim asc As Object
Dim enc As Object
Dim TextToHash() As Byte
Dim SharedSecretKey() As Byte
Dim bytes() As Byte
Set asc = CreateObject("System.Text.UTF8Encoding")
Set enc = CreateObject("System.Security.Cryptography.HMACSHA1")
TextToHash = asc.GetBytes_4(sTextToHash)
SharedSecretKey = asc.GetBytes_4(sTextToHash)
enc.Key = SharedSecretKey
bytes = enc.ComputeHash_2((TextToHash))
BASE64SHA1 = EncodeBase64(bytes)
Set asc = Nothing
Set enc = Nothing
End Function
Private Function EncodeBase64(ByRef 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
Set objNode = Nothing
Set objXML = Nothing
End Function
Everything was working great, running under Excel 2013 (Portuguese), Windows 8.1 (Portuguese) and Windows 7.
Although, when I start using another computer which uses the same Excel 2013 (Portuguese) but the Windows 8.1 (English), not sure why and if this is the reason, but it came up with the error and the debugger highlighted the first line in BASE64SHA1
function, after variables declaration:
Set asc = CreateObject("System.Text.UTF8Encoding")
Error:
Runtime Error -2146232576 (80131700)
I checked the error messages and came with the details below:
err.Source - VBAProject
err.HelpContext - 1000440
err.HelpFile - C:\Program Files (x86)\Common Files\Microsoft Shared\VBA\VBA7.1\1046\VbLR6.chm
err.LastDllError - 0
Can anyone help? Looks like I am missing a Reference or something... but I have declared as Object, and it worked fine on other PCs...