今天来聊一聊一种被广泛使用的密码加密存储方案:加盐哈希。
本文包含以下内容:
- 什么是盐?
- 什么是哈希算法?
- 加密与校验过程。
- C#实现。
什么是盐?
In cryptography, a salt is random data that is used as an additional input to a one-way function that hashes data, a password or passphrase. -- From Wiki.
其实说白了,盐就是在密码学中用于加密的随机数据。
什么是哈希算法?
A cryptographic hash function (CHF) is a hash function that is suitable for use in cryptography. It is a mathematical algorithm that maps data of arbitrary size (often called the "message") to a bit string of a fixed size (the "hash value", "hash", or "message digest") and is a one-way function, that is, a function which is practically infeasible to invert. -- From Wiki.
密码哈希函数(CHF)是适用于密码学的哈希函数。