I need to write THIS in php
https://cryptii.com/pipes/QiZmdA
I have tried those but don’t produce the same result
<?php
echo hash_hmac('sha1', '002590cd26da', "8544e3b47eca58f9583043f8");
echo var_dump(hash_hmac("sha1", "002590cd26da", pack("H*", "8544e3b47eca58f9583043f8")));
?>
what am i doing wrong ?
Thanks in advance
2
Answers
thanks figures out it will also work like this
$t=hash_hmac('sha1', pack("H*", $macaddr), pack("H*", '8544e3b47eca58f9583043f8'));
cheers
You need convert the hex string to binary first then use function
hash_hmac
with ‘true’ parameter to get binary output and last,convert the binary HMAC to a hex string.Here fixed example code :
The code will produce output :
HMAC: 857ab7a94a4c103e3a8cc0442db0d4745064bb73
Live test : https://3v4l.org/q4rJj