public void GenerateSaltedHash_CompareAlrdyHashedAnHashedThere_ReturnsNotEqual() { byte[] salt = AtlasCrypto.GetSalt(); string alrdyHashedPassword = "******"; string password = "******"; byte[] encryptedPassword = AtlasCrypto.GenerateSaltedHash(Encoding.UTF8.GetBytes(password), salt); Assert.NotEqual(alrdyHashedPassword, Convert.ToBase64String(encryptedPassword)); }
public void SignIn_SuccessfulAdminExecuteNoException_ReturnsTrue() { using (UnitOfWork unitOfWork = new()) { Encoding enc = Encoding.UTF8; var salt = (from user in unitOfWork.BookingUsers.Get() where user.UserLogin.Equals("admin") select user).Single(); string result1 = Convert.ToBase64String(AtlasCrypto. GenerateSaltedHash(enc.GetBytes("125478963"), Convert.FromBase64String(salt.Salt))); Assert.Equal(result1, salt.UserPassword); } }
private void Save() { try { if (ValidatePassword(UnsecurePassword)) { byte[] salt = AtlasCrypto.GetSalt(); SelectedUser.UserPassword = Convert.ToBase64String(AtlasCrypto.GenerateSaltedHash(Encoding.UTF8.GetBytes(UnsecurePassword), salt)); SelectedUser.Salt = Convert.ToBase64String(salt); } using (UnitOfWork unit = new()) { unit.AddressRepository.Update(SelectedAddress); unit.BookingUsers.Update(SelectedUser); unit.Save(); } } catch (Exception e) { FakeAtlasMessageBoxService box = new(); box.ShowMessage(e.Message); } }
public void GetSalt_2Times_ReturnsNotEqual() { byte[] salt1 = AtlasCrypto.GetSalt(); byte[] salt2 = AtlasCrypto.GetSalt(); Assert.NotEqual(salt1, salt2); }