ribble has asked for the wisdom of the Perl Monks concerning the following question:
Hello all. I am after some assistance regarding the creation of a basic authentication header.
I am been asked to code against a restAPI that requires the creation of the authentication header using hmac sha256. I am running into issues getting the hash values to match against the restAPI yet when I check using an online hmac generator my values are correct
This leads me to believe I am doing something wrong when using the app key as part of the hash
The documentation states that the key is comprised of 32 two-character base-16 hexadecimal values. I guess this where my issue is
I don't know how I should be handling the key other than just parsing it as a string.
my simple code so far
#set the strings $method="GET"; $appid="d6468df6c1e8419fb5ec50f62be9a28b"; $appkey="15c7a6e1a5bd73500db29dffd0e19b6c6228b044c64348a6f5d6d470c54fc +208"; $path="/xxxxx/xxxx/api/v1/users/xxxx/xxxxx"; #build the string to hash $step1="$method\\n $datestring\\n $appid\\n $path"; #hmac sha256hash the string $step2=hmac_sha256_hex($step1, $appkey);
I am using hmac_sha256_hex as the app key string is in hex. I am clearly doing something wrong but no idea what?
Do i need to perform some conversion of the app key before using it? I am lost!
thanks for looking
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HMAC Sha256 Help!
by hippo (Archbishop) on Jul 18, 2017 at 09:21 UTC | |
by ribble (Novice) on Jul 18, 2017 at 12:06 UTC | |
|
Re: HMAC Sha256 Help! (updated)
by haukex (Archbishop) on Jul 18, 2017 at 09:23 UTC | |
by ribble (Novice) on Jul 18, 2017 at 12:29 UTC | |
by haukex (Archbishop) on Jul 18, 2017 at 16:42 UTC | |
by ribble (Novice) on Jul 18, 2017 at 19:23 UTC | |
by poj (Abbot) on Jul 18, 2017 at 20:37 UTC | |
|
Re: HMAC Sha256 Help!
by fishy (Friar) on Jul 18, 2017 at 16:28 UTC | |
by ribble (Novice) on Jul 18, 2017 at 19:28 UTC |