원래 PHP 인증 확인을 python3으로 옮겨야합니다. 이 같은 코드를 가지고 :PHP Bcrypt가 Python3으로 이동
// hash from db
$hash = "$2y$14$00sMXcXPyTthEv9m5dszwuT8VUU6KK1HtCunemfutphrbCHZoIz0e";
// the hash is used as salt
$result = crypt($password, $hash);
//result should match the hash if pasword is correct
$result = "$2y$14$00sMXcXPyTthEv9m5dszwuT8VUU6KK1HtCunemfutphrbCHZoIz0e";
그것은 매개 변수의 비용으로 수행 =
python3에서 그것을 구현하는 가장 좋은 LIB은 무엇입니까 (14)?
편집 : 나는 py-bcrypt을 사용했습니다.
>>> import bcrypt
>>> password = "ahoj"
>>> db_hash = "$2y$14$00sMXcXPyTthEv9m5dszwuT8VUU6KK1HtCunemfutphrbCHZoIz0e"
>>> computed_hash = bcrypt.hashpw(password, db_hash)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Invalid salt
소금이 유효하지 않은 이유는 무엇입니까? PHP에서
그것은 작동합니다
password=ahoj
hash=$2y$14$00sMXcXPyTthEv9m5dszwuT8VUU6KK1HtCunemfutphrbCHZoIz0e
result=$2y$14$00sMXcXPyTthEv9m5dszwuT8VUU6KK1HtCunemfutphrbCHZoIz0e
파이썬에서 다른 무엇입니까? 당신이 암호를 비교하려면
표준 bcrypt 해시이므로 모든 라이브러리에서 처리합니다. –