Last active
September 15, 2021 21:41
-
-
Save motin/7cbe1ae77bf493e3cae8 to your computer and use it in GitHub Desktop.
PHP equivalent of hmac.new(secret, message, hashlib.sha256).hexdigest()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$message = 'Message'; | |
$secret = 'secret'; | |
print "php\n"; | |
print hash_hmac('SHA256', $message, $secret) . "\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hmac | |
import hashlib | |
message = 'Message' | |
secret = 'secret' | |
print 'python' | |
print hmac.new(secret, message, hashlib.sha256).hexdigest() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python bin/hmac-sign.py && php bin/hmac-sign.php | |
python | |
aa747c502a898200f9e4fa21bac68136f886a0e27aec70ba06daf2e2a5cb5597 | |
php | |
aa747c502a898200f9e4fa21bac68136f886a0e27aec70ba06daf2e2a5cb5597 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a python3 script that works to call an API, but I need to reproduce in PHP as it will be used in a wordpress site and calling out to run a python script is proving difficult on my client's (godaddy) server.
the php equivalent hash_hmac() isn't working. Thoughts?