I am trying to calculate the Activation Code from Product Secret and Device Serial Number, my calculated Activation Code is always different from Xively's.
Can someone please help me to point out where I am wrong?
From Xievely web portal:
Product ID: 4sA5tK9XF_3xKfOawmyO
Product Secret: be0f6928e3653cf175b7f8ebb2da50c6658b30b7
Serial Number: 123123123
Activation Code: 93d80b284a19d14e99d9abb7d637afc59d4b0f95
I tested with PHP:
echo hash_hmac("sha1","123123123","be0f6928e3653cf175b7f8ebb2da50c6658b30b7");
Activation code I generated is: 66b02f4c691287144c09e3b76816275742c155b5 which is different from Xively's.
Please help, thanks a million.
Provided that you are using PHP 5 you can convert the secret into binary using hex2bin() and this should work. Try this:
$secret_string='be0f6928e3653cf175b7f8ebb2da50c6658b30b7';
$secret=hex2bin($secret_string);
echo hash_hmac("sha1", '123123123',$secret)."\n";
if no PHP5 you can define hex2bin yourself.
Paul
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With