Skip to content

Commit 50b9011

Browse files
committed
Add hashing unit test
1 parent e4bd4e2 commit 50b9011

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ArchiSteamFarm.Tests/ArchiCryptoHelper.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,21 @@ internal async Task CanEncryptDecryptProtectedDataForCurrentUser() {
6161

6262
await CanEncryptDecrypt(ECryptoMethod.ProtectedDataForCurrentUser).ConfigureAwait(false);
6363
}
64+
65+
[DataRow(EHashingMethod.PlainText, TestPassword)]
66+
[DataRow(EHashingMethod.Pbkdf2, "WlS48GNrs1hAhcNHPfV09TPTLhf03gExb6zpaKiwX5A=")]
67+
[DataRow(EHashingMethod.SCrypt, "9LjhjyugakDQ7Haq/ufyTZDfIGeeWbLcE+/9IeKm8gc=")]
68+
[TestMethod]
69+
internal void CanHash(EHashingMethod hashingMethod, string expectedHash) {
70+
if (!Enum.IsDefined(hashingMethod)) {
71+
throw new InvalidEnumArgumentException(nameof(hashingMethod), (int) hashingMethod, typeof(EHashingMethod));
72+
}
73+
74+
ArgumentException.ThrowIfNullOrEmpty(expectedHash);
75+
76+
string hashed = Hash(hashingMethod, TestPassword);
77+
78+
Assert.AreEqual(expectedHash, hashed);
79+
}
6480
}
6581
#pragma warning restore CA1812 // False positive, the class is used during MSTest

0 commit comments

Comments
 (0)