5 python encryption hash sha1 hashlib
我正在尝试加密sha1中的字符串,我从服务器收到错误:
"No Module Named hashlib"
Run Code Online (Sandbox Code Playgroud)
通过使用以下代码:
import hashlib
encrypted = hashlib.sha1(string)
encrypted = encrypted.digest()
Run Code Online (Sandbox Code Playgroud)
我会感激任何帮助,
谢谢,盖伊多尔
你可能有一个<2.5的python版本.请改用sha模块.
这是差异:
>>> import sha
>>> s = sha.new()
>>> s.update('hello')
>>> s.digest()
'\xaa\xf4\xc6\x1d\xdc\xc5\xe8\xa2\xda\xbe\xde\x0f;H,\xd9\xae\xa9CM'
Run Code Online (Sandbox Code Playgroud)
VS
>>> import hashlib
>>> hashlib.sha1('hello').digest()
'\xaa\xf4\xc6\x1d\xdc\xc5\xe8\xa2\xda\xbe\xde\x0f;H,\xd9\xae\xa9CM'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7517 次 |
| 最近记录: |