public static async Task <string> Decrypt(EncryptedResult encryptedResult)
        {
            string decrypted;

            using (Aes aes = Aes.Create()) {
                aes.Key = encryptedResult.Key;
                aes.IV  = encryptedResult.IV;
                ICryptoTransform decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
                using (MemoryStream memoryDecrypt = new MemoryStream(encryptedResult.Encrypted)) {
                    using (CryptoStream cryptoStream = new CryptoStream(memoryDecrypt, decryptor, CryptoStreamMode.Read)) {
                        using (StreamReader readerDecrypt = new StreamReader(cryptoStream)) {
                            decrypted = await readerDecrypt.ReadToEndAsync();
                        }
                    }
                }
            }
            return(decrypted);
        }
        public static async Task <EncryptedResult> Encrypt(string password)
        {
            EncryptedResult result = new EncryptedResult();

            using (Aes aes = Aes.Create()) {
                ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
                using (MemoryStream memoryEncrypt = new MemoryStream()) {
                    using (CryptoStream cryptoStream = new CryptoStream(memoryEncrypt, encryptor, CryptoStreamMode.Write)) {
                        using (StreamWriter writerEncrypt = new StreamWriter(cryptoStream)) {
                            await writerEncrypt.WriteAsync(password);
                        }
                        result.Encrypted = memoryEncrypt.ToArray();
                        result.IV        = aes.IV;
                        result.Key       = aes.Key;
                    }
                }
            }
            return(result);
        }
        public async Task <UserSettings> ReadUserSettings()
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AppSettings", "UserSettings.xml");

            this._logger.Information("Settings Path: {0}", path);
            if (File.Exists(path))
            {
                var settings = await this.XmlDeSerializeUserSettings(path);

                var encrypted = new EncryptedResult();
                encrypted.Key       = Convert.FromBase64String(settings.Key);
                encrypted.IV        = Convert.FromBase64String(settings.IV);
                encrypted.Encrypted = Convert.FromBase64String(settings.Password);
                settings.Password   = await EncryptionService.Decrypt(encrypted);

                return(settings);
            }
            else
            {
                this._logger.Error("Failed to read UserSettings,IUserSettingsService");
                return(null);
            }
        }