BCrypt.Net ดูเหมือนจะเป็นไลบรารีที่ได้รับความนิยมมากที่สุดในขณะนี้
http://bcrypt.codeplex.com/
นี่คือตัวอย่างวิธีใช้สำหรับการแฮชรหัสผ่าน:
[TestMethod]
public void BCryptTest()
{
const string password = "PASSWORD";
const int workFactor = 13;
var start = DateTime.UtcNow;
var hashed = BCrypt.Net.BCrypt.HashPassword(password, workFactor);
var end = DateTime.UtcNow;
Console.WriteLine("hash length is {0} chars", hashed.Length);
Console.WriteLine("Processing time is {0} with workFactor {1}", end - start, workFactor);
Console.WriteLine("Hashed password: {0} ", hashed);
Console.WriteLine("correct password {0}", BCrypt.Net.BCrypt.Verify("PASSWORD", hashed));
Console.WriteLine("incorrect password {0}", BCrypt.Net.BCrypt.Verify("PASSWORd", hashed));
}
ตัวอย่างผลลัพธ์:
hash length is 60 chars
Processing time is 00:00:01.0020000 with workFactor 13
Hashed password: $2a$13$iBqdG7ENBABEargiyzGlTexPsmviF/qrFxUZB2zce7HKF6MoBNhEq
correct password True
incorrect password False