密码的存储和验证方案
密码的存储和验证方案

密码的存储和验证方案

Created time
May 6, 2022 03:38 AM
Tags
blog
系统设计
密码存储
Priority
Status
Date
May 6, 2022
 

密码存储

notion image
 
  1. 用户输入 password
  1. 系统生成随机的字符串,我们称为 salt,符合 OWASP 标准
  1. passwordsalt 拼接起来,通过哈希函数计算出拼接后的密码字符串的哈希值
  1. salthash 存储至 DB 中

密码验证

notion image
 
  1. 用户输入密码,系统从 DB 中取出 salt
  1. 将用户输入的密码和系统中的 salt 进行拼接,得到 password+salt
  1. 计算 password+salt 的哈希,我们暂且将其称为 hash1
  1. 从 DB 中取出原本的哈希值,我们称其为 hash2
  1. 比较 hash1hash2 ,得到验证结果