3
我在谷歌搜索,很遺憾,我找不到任何我期望的答案。如何使用BCrypt for SQL Server的.Net實現?
我已經下載.NET implementation of BCrypt
誠實,我通常是在PHP語言編碼,我有像淨
事情我在谷歌搜索,很遺憾,我找不到任何我期望的答案。如何使用BCrypt for SQL Server的.Net實現?
我已經下載.NET implementation of BCrypt
誠實,我通常是在PHP語言編碼,我有像淨
事情我假設你已經擁有的架構,用於存儲用戶不知道散列某種用戶配置文件表?
比方說,此表的格式如下:
PersonID int PrimaryKey
PersonName nvarchar(50)
PersonPasswordHash varchar(128)
PersonPasswordSalt nvarchar(10)
然後在你的.NET代碼(例如C#),你會繼續前進,執行以下操作,當你創建一個新用戶
string passwordPlain = txtPassword.Text; // This is the password entered by the user
/* a work factor of 10 is default, but you can mention any thing from 4 to 31.
But keep in mind that for every increment in work factor the work increases
twice (its 2**log_rounds)
*/
string passwordSalt = BCrypt.GenerateSalt(10);
string passwordHash = BCrypt.HashPassword(passwordPlain, passwordSalt);
// Now store the passwordHash and passwordSalt in the database for that user
當您具有上述值後,將在數據庫中存儲適當的值。
當它的時間來驗證登錄,檢索從數據庫中passwordHash
和passwordSalt
的細節,你可以驗證如下:
string originalPasswordSalt; // retireive its value from the DB
string originalPasswordHash; // retireive its value from the DB
string givenPasswordPlain = txtPassword.Text; // given by the user during login
string givenPasswordHash = BCrypt.HashPassword(givenPasswordPlain, originalPasswordSalt);
if(givenPasswordHash.Equals(originalPasswordHash)) { // you have an valid user
} else { // given login name or password is not valid
}
首先,我想說對不起,也許我的問題是不夠清楚。 我想知道如何在T-SQL中使用BCrypt,你介紹一些關於在T-SQL中使用BCrypt的例子嗎? – 2013-02-20 10:41:20
檢查http://blog.tcs.de/using-the-bcrypt-hash-algorithm-in-ms-sql-server/ – 2013-02-20 14:00:00
謝謝!這真的很有幫助。 – 2013-02-20 21:12:31