コード例 #1
0
ファイル: ConnectEntryPoint.cs プロジェクト: philip4077/Emby
        private void CacheAddress(IpAddressInfo address)
        {
            if (_cachedIpAddress != null && _cachedIpAddress.Equals(address))
            {
                // no need to update the file if the address has not changed
                return;
            }

            var path = CacheFilePath;

            try
            {
                _fileSystem.CreateDirectory(Path.GetDirectoryName(path));
            }
            catch (Exception ex)
            {
            }

            try
            {
                _fileSystem.WriteAllText(path, _encryption.EncryptString(address.ToString()), Encoding.UTF8);
                _cachedIpAddress = address;
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error saving data", ex);
            }
        }
コード例 #2
0
        public override void UpdateConfiguration(BasePluginConfiguration configuration)
        {
            var config = (PluginConfiguration)configuration;

            // Encrypt password for saving.  The Password field the config page sees will always be blank except when updated.
            // The program actually uses the encrypted version

            config.PwData   = _encryption.EncryptString(config.Password ?? string.Empty);
            config.Password = null;


            base.UpdateConfiguration(configuration);
        }
コード例 #3
0
        private void CacheData()
        {
            var path = CacheFilePath;

            try
            {
                Directory.CreateDirectory(Path.GetDirectoryName(path));

                var json = _json.SerializeToString(_data);

                var encrypted = _encryption.EncryptString(json);

                File.WriteAllText(path, encrypted, Encoding.UTF8);
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error saving data", ex);
            }
        }
コード例 #4
0
 private string EncryptPassword(string password)
 {
     return(PasswordHashPrefix + _encryption.EncryptString(password));
 }