码迷,mamicode.com
首页 > 编程语言 > 详细

python import hashllb

时间:2019-04-19 01:06:41      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:admin   self   pytho   16进制   SHA256   string   sha1   htm   ash   

http://www.cnblogs.com/alex3714/articles/5161349.html

用于加密相关的操作,3.x里代替了md5模块和sha模块,主要提供 SHA1, SHA224, SHA256, SHA384, SHA512 ,MD5 算法

 

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
‘‘‘
def digest(self, *args, **kwargs): # real signature unknown
""" Return the digest value as a string of binary data. """
pass

def hexdigest(self, *args, **kwargs): # real signature unknown
""" Return the digest value as a string of hexadecimal digits. """
pass

‘‘‘
import hashlib

# ######## 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 import hashllb

标签:admin   self   pytho   16进制   SHA256   string   sha1   htm   ash   

原文地址:https://www.cnblogs.com/jasonLiu2018/p/10733359.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!