Python Digest (hashing algorithm): Hashlib

Source: Internet
Author: User
Tags md5 hash sha1


Abstract 1:MD5

Import hashlibmd5 = Hashlib.md5 () print (MD5) print (Md5.update (' How to use MD5 in Python hashlib? '). Encode (' Utf-8 ')) print (Md5.hexdigest ())

run Result:

<md5 HASH Object @ 0x7fac5fae0f80>noned26a53750bc40b38b65a520292f69306



Abstract 2:SHA1

IMPORT&NBSP;HASHLIBSHA1&NBSP;=&NBSP;HASHLIB.SHA1 () sha1.update (' how to use sha1 in  '). Encode (' Utf-8 ')) sha1.update (' Python hashlib? '). Encode (' Utf-8 ')) print (Sha1.hexdigest ()) 

Operation Result:

2c76b57293ce30acef38d98f6046927161b46a44



Add Salt: salt

This is a custom algorithm.

The same string can get the same MD5 value, in order to strengthen the guard, you can use: Password + user's account name + fixed custom string, and then encryption,

In this way, the obtained MD5 value is unique, making the crack more difficult.



Python Digest (hashing algorithm): 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.