I'm trying to write a few functions to sign messages in order to send to Amazon's AWS. I've almost got it, but I think I need some help from someone who knows dot net a bit better than me.
I need to sha256 some things (not hmacsha256), but I'm getting some incorrect results. Below is my sha256 function based on the Plain SHA1 function found here: https://www.alphasoftware.com/docume...tal%20Hash.xml
However, it gives me incorrect results. Based on the tests here: http://docs.aws.amazon.com/general/l...est-suite.html when I hash this value:
I should get this value in return (verified with http://www.xorbin.com/tools/sha256-hash-calculator):
, however I get
After doing some research, i found this post on SO: http://stackoverflow.com/questions/1...ng-with-sha256 That states the default encoding for dotnet is utf16, but AWS uses utf8.
So, my question is, how do I change the encoding type for my sha function? It appears that I need to somehow seed my data blob variable as utf8 encoding, but I'm not sure how to do that.
Thanks!
I need to sha256 some things (not hmacsha256), but I'm getting some incorrect results. Below is my sha256 function based on the Plain SHA1 function found here: https://www.alphasoftware.com/docume...tal%20Hash.xml
Code:
function sha256 as c (string as c) dim data as b data = convert_acp_to_utf8(string) dim result as b dim sham as ::System::Security::Cryptography::SHA256Managed = new ::System::Security::Cryptography::SHA256Managed() result = sham.ComputeHash(data) sha256 = *to_hex(result) end function
Code:
[COLOR=#444444][FONT=&]GET [/FONT][/COLOR]/ Param1=value1&Param2=value2 host:example.amazonaws.com x-amz-date:20150830T123600Z host;x-amz-date [COLOR=#444444][FONT=&]e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855[/FONT][/COLOR]
Code:
[COLOR=#444444][FONT=&]816cd5b414d056048ba4f7c5386d6e0533120fb1fcfa93762cf0fc39e2cf19e0[/FONT][/COLOR]
Code:
9e487d40177520aed8763d24c77c7179f67622debbd2b8188d93138ba6748ade
So, my question is, how do I change the encoding type for my sha function? It appears that I need to somehow seed my data blob variable as utf8 encoding, but I'm not sure how to do that.
Thanks!
Comment