在django中使用User.objects.create_user()    时  ,会自动给密码加密,其中的User为Auth模块中的User。(User.objects.create() 不会对密码加密  )

 

def hash_password(password):
    if isinstance(password, str):
        password = password.encode('utf-8')
    return hashlib.md5(password).hexdigest().upper()

 

 了解make_password()的用法。

相关文章:

  • 2022-02-13
  • 2022-12-23
  • 2021-07-23
  • 2022-03-04
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
猜你喜欢
  • 2021-11-03
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-16
  • 2022-12-23
  • 2021-12-06
相关资源
相似解决方案