經過django自帶的類庫,來加密解密很方便,下面來簡單介紹下;django
導入包:加密
from django.contrib.auth.hashers import make_password, check_passwordcode
make_password 是生成密碼hash
check_password是效驗密碼import
make_password("123456")
獲得結果:加密解密
u'pbkdf2_sha256MAjic3nDGFoi$qbclz+peplspCbRF6uoPZZ42aJIIkMpGt6lQ+Iq8nfQ='密碼
效驗密碼是否正確im
check_password("123456","pbkdf2_sha256MAjic3nDGFoi$qbclz+peplspCbRF6uoPZZ42aJIIkMpGt6lQ+Iq8nfQ=")
Trueword