【MondoDB】パスワード暗号化

 

import hashlib
from passlib.hash import pbkdf2_sha256


print(hashlib.algorithms_available)
print(hashlib.algorithms_guaranteed)

password ='abcd1234'

# hash
_hash = pbkdf2_sha256.encrypt(password, rounds=200000, salt_size=16)
print(_hash)

 #save hash
# verify
if pbkdf2_sha256.verify(password, _hash):
  resp['status']='OK'
else:
  resp['status']='NG'

 

Leave a Reply