BCrypt
BCrypt 只能單向加密! 不能反向解密!
應用
那要怎麼在C#中應用呢?
先利用NuGet 下載 BCrypt.Net
並配合下列程式碼
using BCryptHelper = BCrypt.Net.BCrypt;
public class Cryptography
{
public static string Hash(string Text, out string Salt)
{
Salt = BCryptHelper.GenerateSalt();
return BCryptHelper.HashPassword(Text, Salt);
}
public static bool VerifyHash(string Text, string HashedText)
{
return BCryptHelper.Verify(Text, HashedText);
}
}
方法: 1. 利用亂數加密後的密碼 Hash(要被加密的字串, out 亂數產生的字串)
2. 密碼是否相符 VerifyHash(輸入的字串,亂數加密後的密碼)
Last updated
Was this helpful?