mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-16 06:20:34 +00:00
Add hashing unit test
This commit is contained in:
@@ -61,5 +61,21 @@ internal sealed class ArchiCryptoHelper {
|
||||
|
||||
await CanEncryptDecrypt(ECryptoMethod.ProtectedDataForCurrentUser).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[DataRow(EHashingMethod.PlainText, TestPassword)]
|
||||
[DataRow(EHashingMethod.Pbkdf2, "WlS48GNrs1hAhcNHPfV09TPTLhf03gExb6zpaKiwX5A=")]
|
||||
[DataRow(EHashingMethod.SCrypt, "9LjhjyugakDQ7Haq/ufyTZDfIGeeWbLcE+/9IeKm8gc=")]
|
||||
[TestMethod]
|
||||
internal void CanHash(EHashingMethod hashingMethod, string expectedHash) {
|
||||
if (!Enum.IsDefined(hashingMethod)) {
|
||||
throw new InvalidEnumArgumentException(nameof(hashingMethod), (int) hashingMethod, typeof(EHashingMethod));
|
||||
}
|
||||
|
||||
ArgumentException.ThrowIfNullOrEmpty(expectedHash);
|
||||
|
||||
string hashed = Hash(hashingMethod, TestPassword);
|
||||
|
||||
Assert.AreEqual(expectedHash, hashed);
|
||||
}
|
||||
}
|
||||
#pragma warning restore CA1812 // False positive, the class is used during MSTest
|
||||
|
||||
Reference in New Issue
Block a user