PHP Hash_hmac matches python HMAC SHA1 ____php

Source: Internet
Author: User
Tags hmac sha1

Because of different languages, the rules for encryption are slightly different. Then this problem in the Niang can not search a correct answer, hereby record. 1. First, the two basic algorithms need to be consistent, here are the basic rules of SHA1 2.python section, if you are using digest () output, the PHP section must use raw binary data output.

Python:hmac.new (' Test ', ' test ', HASHLIB.SHA1). Digest ()
Php:hash_hmac (' SHA1 ', ' Test ', ' test ', true);
3.python Part If you are using Hexdigest () output, the PHP section removes the last raw data parameter to match.
Python:hmac.new (' Test ', ' test ', HASHLIB.SHA1). Hexdigest ()
php:hash_hmac (' SHA1 ', ' Test ', ' test ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.