Python中,这样加密用户密码,有什么需要改进的?

查看:128
本文介绍了Python中,这样加密用户密码,有什么需要改进的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

描述问题

想安全地存储用户密码

上下文环境

  1. Python27

  2. Linux-Server

相关代码

解决方案

最好的方法当然是永远不要decrypt

你看下这里的例子:

https://paragonie.com/blog/20...

import bcrypt
import hmac

# Calculating a hash
password = b"correct horse battery staple"
hashed = bcrypt.hashpw(password, bcrypt.gensalt())
# Validating a hash (don't use ==)
if (hmac.compare_digest(bcrypt.hashpw(password, hashed), hashed)):
    # Login successful

bcrypt妥妥的

这篇关于Python中,这样加密用户密码,有什么需要改进的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆