[英]How to compare hashed password to Input() in Python?
目標:
目前正在學習如何使用 Python 加密密碼。
當前代碼:
import bcrypt
passwd = b'False'
salt = bcrypt.gensalt()
hashed = bcrypt.hashpw(passwd, salt)
x = input()
print(hashed == bcrypt.hashpw(x, hashed))
問題:
我可能做錯了,需要一些指導如何正確實現這一點。
如何在b''
的撇號之間插入輸入值? 這就是密碼所在的位置,並與哈希密碼進行比較。
這是我嘗試過的(另外,我在正確的路線上?):
x = b'%s' % (input())
CMD 輸出
x = b'%s' % (input())
TypeError: %b requires a bytes-like object, or an object that implements __bytes__, not 'str'
目標
我正在嘗試將輸入與散列密碼進行比較。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.