private string DecryptConnectionString(RootConnection connection) { var encryptionSaltSetting = _settingRepository.FindSettingAsString(SettingName.EncryptionSalt); var encryptionKeySetting = _settingRepository.FindSettingAsString(SettingName.EncryptionKey); if (string.IsNullOrWhiteSpace(encryptionSaltSetting)) { throw new ServiceException(ResponseCode.NotFound, "Encryption Salt can not be found."); } if (string.IsNullOrWhiteSpace(encryptionKeySetting)) { throw new ServiceException(ResponseCode.NotFound, "Encryption Key can not be found."); } var connectionString = new Encryption( encryptionKeySetting, encryptionSaltSetting, connection.ConnectionGuid.ToByteArray()) .DecryptString(connection.EncryptedConnectionString); return(connectionString); }