Python Cryptographic Module Hashlib

Source: Internet
Author: User
Tags sha1

Hashlib Module Hashlib module, mainly used for encryption-related operations.

In the Python3 version, instead of the MD5 and SHA modules, mainly provide SHA1, SHA224, SHA256, SHA384, SHA512, MD5 algorithm.

import hashlib m = hashlib. MD5() m. Update(b"Hello") m. Update(b"It ' s Me") print(m. Digest()) m. Update(b"It ' s been a long time since last time we ...") print(m. Digest()) #2进制格式hash Print(len(m. Hexdigest())) #16进制格式hash # ######## MD5 ########hash = hashlib. MD5() Hash. Update(' admin ') print(hash. Hexdigest()) # ######## SHA1 ######## hash = hashlib. SHA1() Hash. Update(' admin ') print(hash. Hexdigest()) # ######## sha256 ########hash = hashlib. sha256() Hash. Update(' admin ') print(hash. Hexdigest()) # ######## sha384 ########hash = hashlib. sha384() Hash. Update(' admin ') print(hash. Hexdigest()) # ######## sha512 ######## hash = hashlib. sha512() Hash. Update(' admin ') print(hash. Hexdigest())

Python Cryptographic Module Hashlib

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.