The double equals in the api key is padding. (https://en.wikipedia.org/wiki/Base64#Padding) Will you please try your code without it, and report back?
Thanks Paul Spiliosv wrote > Dear Sven, > > First of all thank you for your prompt reply. > > I will try and include the information you have requested. > > The SHA256 implementation comes from here > http://smalltalkhub.com/#!/~Cryptography/Cryptography and I loaded only > the latest version of Cryptography into a fresh pharo 2.0 image, and > nothing else. > > I need this hmacsha256 encryption for a rest implementation I am trying > out, for which I have a VB implementation and I get the correct values for > both sets of data. > > It seems that the SHA256 (encodedSignature) hex value is correct on both > occasions and the base64 encodedForHTTP value for the apiKey := > '123456789' is also correct, but for the case where apiKey := > 'veQC+IBLq5qMO8oGcQupjg==' I get the base64 encodedForHTTP value of > 'AcTXF%2BlDa2kRYVm0k5jY6pGGTMXD7NsQS6tLBXRp3Xs%3D' where I should get > '%2B%2FYhVkcaEIHBeUESOsJYD1nKyJXVGyFX%2FlxR616aUK4%3D'. > The two sets of testing code are: > 1) Produces correct result. > apiKey := '123456789'. > unsignedSignature := 'pharmacistprescriptionsget000001'. > encodedSignature := (SHA256 new) hmac key: apiKey asByteArray; > digestMessage: unsignedSignature asByteArray. > encodedSignature base64Encoded encodeForHTTP. > > 2) > apiKey := 'veQC+IBLq5qMO8oGcQupjg=='. > userName := 'testpharm'. > barCode :='1403122014500'. > unsignedSignature := userName,'prescriptionsgetexecuted',barCode. > encodedSignature := (SHA256 new) hmac key: apiKey asByteArray; > digestMessage: unsignedSignature asByteArray. > encodedSignature base64Encoded encodeForHTTP. > > Is the above enough? > Regards, Spilios > > Now I understand why I see the long emails/replies! -- View this message in context: http://forum.world.st/Base64-or-HMAC-problem-tp4756788p4756836.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
