回答編集履歴

1

別解の追記

2021/03/10 15:59

投稿

torofieldchan
torofieldchan

スコア39

test CHANGED
@@ -21,3 +21,11 @@
21
21
 
22
22
 
23
23
  なので、パスワードそのものをDBに格納しない場合、hashlib.contextを使うのではなく、純粋にハッシュ関数(sha256)を使えばいいと思います。
24
+
25
+
26
+
27
+ あるいは、DB(user.password)にHASHの結果を格納しているのだとしたら、以下でも行けるはずです。
28
+
29
+
30
+
31
+ pwd_context.verify(password, user.password)