mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
migrating to .NET Core 2.0
This commit is contained in:
42
SharedLibraryCore/Helpers/Hashing.cs
Normal file
42
SharedLibraryCore/Helpers/Hashing.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using SimpleCrypto;
|
||||
|
||||
namespace SharedLibraryCore.Helpers
|
||||
{
|
||||
public class Hashing
|
||||
{
|
||||
/// <summary>
|
||||
/// Generate password hash and salt
|
||||
/// </summary>
|
||||
/// <param name="password">plaintext password</param>
|
||||
/// <returns></returns>
|
||||
public static string[] Hash(string password, string saltStr = null)
|
||||
{
|
||||
|
||||
string hash;
|
||||
string salt;
|
||||
var CryptoSvc = new PBKDF2();
|
||||
|
||||
// generate new hash
|
||||
if (saltStr == null)
|
||||
{
|
||||
hash = CryptoSvc.Compute(password);
|
||||
salt = CryptoSvc.Salt;
|
||||
return new string[]
|
||||
{
|
||||
hash,
|
||||
salt
|
||||
};
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
hash = CryptoSvc.Compute(password, saltStr);
|
||||
return new string[]
|
||||
{
|
||||
hash,
|
||||
""
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user