通过django自带的类库,来加密解密很方便,下面来简单介绍下;
导入包:
from django.contrib.auth.hashers import make_password, check_password
make_password 是生成密码
check_password是效验密码
make_password("123456")
得到结果:
u'pbkdf2_sha256MAjic3nDGFoi$qbclz+peplspCbRF6uoPZZ42aJIIkMpGt6lQ+Iq8nfQ='
效验密码是否正确
check_password("123456","pbkdf2_sha256MAjic3nDGFoi$qbclz+peplspCbRF6uoPZZ42aJIIkMpGt6lQ+Iq8nfQ=")
True