先导包
from django.contrib.auth.hashers import make_password, check_password
主要是使用make_password来实现加密
使用check_password来检查明文是否对应该密文
>>> from django.contrib.auth.hashers import make_password, check_password
>>> make_password("my", None, 'pbkdf2_sha256')
'pbkdf2_sha256$100000$1sAvOga229RG$r3ZLtkUSRMUleyRUkGA1gJXi7y2oT02bIDF8iRCl+Nw='
>>> make_password("my", None, 'pbkdf2_sha256')
'pbkdf2_sha256$100000$eKY2i0JmdHAo$lD2RZ8D8dqZUgKJM9gF6t7F2wSx32/s0CVWxGFnV1Kc='
>>> check_password("my","pbkdf2_sha256$100000$eKY2i0JmdHAo$lD2RZ8D8dqZUgKJM9gF6t7F2wSx32/s0CVWxGFnV1Kc=")
True
>>>
从上面可见make_password每一次输出的结果都不一致.
check_password输出结果为True/False