我只想在 Python 3 中对字符串(密码)进行哈希处理。我该怎么做?这样做的简单方法是什么?您能否提供一个编码示例或推荐一个可以使用的模块。
您可以使用 Hashlib 在 Python 3 中对值进行哈希处理:
import hashlib
h = hashlib.new('sha256')#sha256 can be replaced with diffrent algorithms
h.update('Hello World'.encode()) #give a encoded string. Makes the String to the Hash
print(h.hexdigest())#Prints the Hash
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10418 次 |
| 最近记录: |