public void ComputeHash_SHA512_Generate_A_String() { // Arrange var salt = HashingManager.CreateSalt(); var plainText = "Password1!"; // Act var hash = HashingManager.ComputeHash(plainText, salt, HashAlgo.SHA512); // Assert Assert.IsInstanceOfType(hash, typeof(string)); }
public void Same_Plain_Text_Salted_Will_Generate_Different_Salted_Hash() { // Arrange var plainText = "Password1!"; // Act var user1Hash = HashingManager.ComputeHash(plainText, HashingManager.CreateSalt(), HashAlgo.SHA256); var user2Hash = HashingManager.ComputeHash(plainText, HashingManager.CreateSalt(), HashAlgo.SHA256); // Assert Assert.AreNotEqual(user1Hash, user2Hash); }
public void Same_Salt_And_Same_PlainText_Returns_Verify_True() { // Arrange var salt = HashingManager.CreateSalt(); var plainText = "Password1!"; // Act var saltedHash = HashingManager.ComputeHash(plainText, salt, HashAlgo.SHA256); var verify = HashingManager.Verify(plainText, salt, HashAlgo.SHA256, saltedHash); // Assert Assert.IsTrue(verify); }
public void Same_Salt_And_Different_PlainText_Returns_Verify_False() { // Arrange var salt = HashingManager.CreateSalt(); var originalPlainText = "Password1!"; var differentPlainText = "Password2!"; // Act var saltedHash = HashingManager.ComputeHash(originalPlainText, salt, HashAlgo.SHA256); var verify = HashingManager.Verify(differentPlainText, salt, HashAlgo.SHA256, saltedHash); // Assert Assert.IsFalse(verify); }