public void CreateHash_NullInput_Throws() { // Arrange var algorithm = new PBKDF2(); // Act && Assert Assert.Throws <ArgumentNullException>(() => algorithm.CreateHash(null)); }
public void Expect_Equal() { var hash = Convert.FromBase64String("+WqsZSS2m8iId8QQAayiIS6bLUj4R/Caem72blANo20="); var salt = Convert.FromBase64String("fcOMenFOG3yx8khQ4m0MMAIhhHZ1qKLD4wH23CH8hCs="); var result = PBKDF2.CreateHash("echoes", salt, 64000, hash.Length); Assert.AreEqual(hash, result); }
public void IsThisAlgorithm_ValidInput_ReturnsTrue() { // Arrange var algorithm = new PBKDF2(); // Act var hash = algorithm.CreateHash("Hello world"); var isThisAlgorithm = algorithm.IsThisAlgorithm(hash); // Assert Assert.True(isThisAlgorithm); }
public void CreateHash_ProperInput_Hashes() { // Arrange var algorithm = new PBKDF2(); // Act var hash = algorithm.CreateHash("Hello world"); // Assert Assert.NotNull(hash); Assert.NotEmpty(hash); }
public void CreateHash_EmptyInput_Hashes() { // Arrange var algorithm = new PBKDF2(); // Act var hash = algorithm.CreateHash(string.Empty); // Assert Assert.NotNull(hash); Assert.NotEmpty(hash); }
public void ValidateHash_MatchingHash_ReturnsTrue() { // Arrange var algorithm = new PBKDF2(); // Act var helloWorldHash = algorithm.CreateHash("Hello world"); var validHash = algorithm.ValidateHash("Hello world", helloWorldHash); // Assert Assert.True(validHash); }
public void ValidateHash_NotMatchingHash_ReturnsFalse() { // Arrange var algorithm = new PBKDF2(); // Act var helloWorldHash = algorithm.CreateHash("Hello world"); var validHash = algorithm.ValidateHash("Definately not hello world", helloWorldHash); // Assert Assert.False(validHash); }
public int Register(string email, string password, string url) { if (ValidEmailFormatCheck(email)) { if (!EmailExistsCheck(email)) { if (ValidPasswordCheck(password, url)) { //insert into myHealthPassDb.Users.Add(new User { Email = email, PasswordHash = PBKDF2.CreateHash(password), LastUpdated = DateTime.Now, DateCreated = DateTime.Now, IsLocked = false, IsLockedOut = false, IsDeleted = false, LockoutTimeStamp = null }); myHealthPassDb.SaveChanges(); return(1); } else { return(-3); } } else { return(-2); } } else { return(-1); } }