Xively Device activation code does not comply with HMAC-SHA1 algorithm

I try to calculate the activation code from the privacy of the product and the serial number of the device, my calculated activation code is always different from the Xively code.

Can someone please help me indicate where I am going wrong?

From the 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"); 

The activation code I generated is: 66b02f4c691287144c09e3b76816275742c155b5 , which is different from Xively's.

Please help, thanks a million.

+5
source share
1 answer

Assuming you are using PHP 5, you can convert the secret to binary using hex2bin (), and this should work. Try the following:

 $secret_string='be0f6928e3653cf175b7f8ebb2da50c6658b30b7'; $secret=hex2bin($secret_string); echo hash_hmac("sha1", '123123123',$secret)."\n"; 

if PHP5 cannot determine hex2bin by itself.

Floor

+1
source

Source: https://habr.com/ru/post/1240814/


All Articles