Best practices for storing passwords in GAE/python

萝らか妹 提交于 2019-12-06 03:50:36

There is a built-in function just for that: https://docs.python.org/2/library/hashlib.html#key-derivation-function.

>>> import hashlib, binascii
>>> dk = hashlib.pbkdf2_hmac('sha256', b'password', b'salt', 100000)
>>> binascii.hexlify(dk)

b'0394a2ede332c9a13eb82e9b24631604c31df978b4e2f0fbd2c549944f9d79a5'

Where salt should be random string stored in databae alongside password. This uses sha256 which seems to be good enough for this purpose.

Getting good (securely random) sald might be a problem, but on newer versions of GAE you can specify pycrypto dependency, and use:

from Crypto.Random import get_random_bytes 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!