python module - hashlib

python module hashlib

import hashlib

m=hashlib.md5() # Generate MD5 encrypted object

m.update('jiami-string'.encode('utf8')) # Pass in a string 'jiami-string' to the object and must be encoded as 'utf8'

m.hexdigest() # Generate a hexadecimal string print(m.hexdigest()) print --> 59e58649d0cd655002b6c101f4663db3

 

s=hashlib.sha256() # Generate sha256 encrypted object

s.update('jiami-string'.encode('utf8')) # Pass in a string 'jiami-string' to the object and must be encoded as 'utf8'

s.hexdigest() # Generate a hexadecimal string print(m.hexdigest()) print

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325036072&siteId=291194637
Recommended