Amazon MWS - Signature Hashing with Access VBA

Hi,

I'm having an issue get the Base64 HMAC on Amazon MWS correctly, I can get the SHA256 one to match perfectly but when I then try to convert to Base64 the result is incorrect, the code I am using to do the SHA256 part is as below

Dim lngLoop As Long
Dim oUTF, oEnc
Dim HMAC() As Byte
Dim strTemp As String
Set oUTF = CreateObject("System.Text.UTF8Encoding")
Set oEnc = CreateObject("System.Security.Cryptography.HMACSHA256")
oEnc.Key = oUTF.GetBytes_4("--------------")
HMAC = oEnc.ComputeHash_2(oUTF.GetBytes_4(StringToSign))
For lngLoop = 0 To UBound(HMAC)
     strTemp = strTemp & LCase(Right("0" & Hex(HMAC(lngLoop)), 2))
Next

Open in new window


But I believe this has be passed to the Base64 encoder as binary or a byte, but i'm having trouble converting a string in Access to a Byte? Is there an easy way to do this?

Cheers
Karl
Kbba04527Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
What is the output and what should it (the expected output) be?
Kbba04527Author Commented:
Hi Gustav,

I should have

SHA 256 HMAC      7b753085a5119a2ebe1ea5f0ae62097391fd1767c84ece94b9dc7a87d8c7f633
Base64 HMAC      e3UwhaURmi6+HqXwrmIJc5H9F2fITs6Uudx6h9jH9jM=

I match the SHA 256      7b753085a5119a2ebe1ea5f0ae62097391fd1767c84ece94b9dc7a87d8c7f633 but for the Base64 I get
N2I3NTMwODVhNTExOWEyZWJlMWVhNWYwYWU2MjA5NzM5MWZkMTc2N2M4NGVjZTk0YjlkYzdhODdkOGM3ZjYzMw==

which as a straight conversion is correct, but I think I should be feeding it in differently?

Cheers
Karl
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MWS

From novice to tech pro — start learning today.