IW4M-Admin/SharedLibraryCore/Helpers/Hashing.cs
RaidMax a863f78678 only unload plugins once at shutdown
clean up some doc warnings
2022-03-24 11:34:32 -05:00

40 lines
992 B
C#

using SimpleCrypto;
namespace SharedLibraryCore.Helpers
{
public class Hashing
{
/// <summary>
/// Generate password hash and salt
/// </summary>
/// <param name="password">plaintext password</param>
/// <param name="saltStr">salt of 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[]
{
hash,
salt
};
}
hash = CryptoSvc.Compute(password, saltStr);
return new[]
{
hash,
""
};
}
}
}