使用PHP在数据库中存储用户密码的最安全方法是什么? [英] What is the most secure way for storing user's passwords inside database using PHP?

查看:110
本文介绍了使用PHP在数据库中存储用户密码的最安全方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪种方法是使用PHP在数据库表内部存储密码的最安全,最有效的方法?

Which is the most secure and most efficient way for storing passwords inside the database tables using PHP?

到目前为止,我已经使用md5()sha256算法来存储密码,如果最终有人可以访问数据库,那么可以使用Rainbow表轻松地破解这两个密码.

So far I have used the md5() and the sha256 algorithm for storing passwords where both of them can be easily hacked using rainbow tables if finally someone gain access on the database.

推荐答案

Bcrypt通常被认为是最安全的选择.

Bcrypt is usually considered the most secure option.

如果您使用的是PHP 5.5,则可以使用新的密码哈希API使其更易于使用. 使用PHP 5.5密码哈希密码哈希API .

If you're using PHP 5.5 you can use the new password hashing API to make it easier to work with. There's a decent tutorial at Hashing Passwords with the PHP 5.5 Password Hashing API.

使用bcrypt是目前公认的哈希密码最佳实践,但是许多开发人员仍在使用诸如MD5和SHA1之类的较早和较弱的算法.一些开发人员甚至在哈希运算时都不使用盐. PHP 5.5中的新哈希算法API旨在引起人们对bcrypt的关注,同时隐藏其复杂性..

这篇关于使用PHP在数据库中存储用户密码的最安全方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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