php - 一种避免在会话和数据库中存储纯文本密码的方法
问题描述
这是一个想法,我必须在会话和 SQL 中都不要存储纯文本密码(即使在帖子中需要)。你能告诉我你对这种方式的看法吗?
//The password entered by user in plain text
$password = $_POST['password'];
//Get data
$req = $db -> prepare('SELECT * FROM users WHERE uid = ?');
$req -> execute(array($_POST['uid']));
$data = $req -> fetch();
//Verifying password
if(password_verify($password, $data['hashed_password']))
{
$_SESSION['rehash'] = password_hash($data['hashed_password'], PASSWORD_DEFAUT);
$_SESSION['uid'] = $_POST['uid'];
}
//When checking credentials on other pages of the website:
if(password_verify($data['hashed_password'], $_SESSION['rehash'])
{
//Private things here
}
我在同一类型的主题上看到了很多主题,即使我不这么认为,如果这是重复的,请随时关闭此主题。
解决方案
推荐阅读
- typescript - 打字稿的全局模块定义
- node.js - 我需要在我的所有网页上运行 node.js
- sql-server - 通过随时间变化的状态对数据进行分组
- angular - 使用 angular-auth-oidc-client@11 的 Angular 身份验证不成功
- python - 使用 Stephen Hansen 的 topicmodels 包可视化 LDA 主题模型
- google-bigquery - 在 BigQuery 中减去最近 3 个月的数据
- javascript - MongoError:没有交易开始
- python - 以 lambda 函数为键的 Sorted() (Timsort) 时间复杂度
- sql - 查询大型 JSON 数组时,使用 T-SQL OPENJSON 是否比返回原始 nvarchar 值更快?
- google-cloud-firestore - 似乎数据存储中的实体使用其祖先键作为其位置的一部分,这可以依赖吗?