我應該如何將資料儲存到我的 MySQL 資料庫中,我應該將什麼型別指定給儲存鹽值的列?
鹽用於安全地儲存資料。如果我們必須安全地儲存使用者密碼,我們需要使用鹽。
$pwd=hash(hash($password) + salt)
然後將 $pwd 儲存在您的系統中,而不是真實密碼。
因此,問題是如何定義鹽值。以下是方法
// if (saltBytes == null)
{
// Define min and max salt sizes.
int minSaltSize = 4;
int maxSaltSize = 8;
// Generate a random number for the size of the salt.
Random random = new Random();
int saltSize = random.Next(minSaltSize, maxSaltSize);
// Allocate a byte array, which will hold the salt.
saltBytes = new byte[saltSize];
// Initialize a random number generator.
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
// Fill the salt with cryptographically strong byte values.
rng.GetNonZeroBytes(saltBytes);
}
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP