public void IntegrationTest() { string value = "cool value"; string encrypted = _transformer.Encrypt(value, out string key, out string iv); string decrypted = _transformer.Decrypt(encrypted, key, iv); Assert.NotEqual(value, encrypted); Assert.Equal(value, decrypted); }
public bool Create(User user) { if (!_repository.IsEmailAvailable(user.Email)) { return(false); } do { user.Id = Guid.NewGuid(); } while (!_repository.IsGuidAvailable(user.Id)); user.Secret = _transformer.Encrypt(user.Secret, out string key, out string iv); user.SecretIv = iv; user.SecretKey = key; user.Password = _hasher.Hash(_generator.GeneratePassword(), out string salt); user.Salt = salt; return(_repository.Create(user)); }