python import hashllb

Posted 潇潇六月雨

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python import hashllb相关的知识,希望对你有一定的参考价值。

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的主要内容,如果未能解决你的问题,请参考以下文章

python中import 点的作用

python中import 点的作用

python,import语法出错

Python中import, from...import,import...as的区别

python import 与 from .... import ...区别

Python的from import和import的区别