Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
 public void GetSalt_2Times_ReturnsNotEqual()
 {
     byte[] salt1 = AtlasCrypto.GetSalt();
     byte[] salt2 = AtlasCrypto.GetSalt();
     Assert.NotEqual(salt1, salt2);
 }