Ejemplo n.º 1
0
        public MusicPlayerService(BaseSettings settings, dcrypt dcrypt)
        {
            _settings = settings;
            _dcrypt   = dcrypt;

            var capturedMemoryStream = new MemoryStream(_dcrypt.Decrypt(Resources.sounds_1046_et_voila));

            _capturedSound = new SoundPlayer(capturedMemoryStream);
        }
Ejemplo n.º 2
0
        public static void Save(BaseSettings settings)
        {
            var encryptHandler = new Func <string, string, string>((_, value) =>
            {
                // Check dcrypt key.
                if (settings.Login.DcryptKey is { })
                {
                    var dcrypt = new dcrypt(Convert.FromBase64String(settings.Login.DcryptKey));
                    return(Convert.ToBase64String(dcrypt.Encrypt(Encoding.UTF8.GetBytes(value))));
                }

                return(value);
            });
Ejemplo n.º 3
0
        public static BaseSettings Load()
        {
            if (!File.Exists(_settingsPath))
            {
                File.WriteAllText(_settingsPath, "");
            }

            var config = ConfigurationParser.Parse <BaseSettings>(_settingsPath);

            var dcrypt = new dcrypt();

            if (config.Login.DcryptKey is null)
            {
                config.Login.DcryptKey = Convert.ToBase64String(dcrypt.Key);
            }

            dcrypt = new dcrypt(Convert.FromBase64String(config.Login.DcryptKey));

            var decryptHandler = new Func <string, string, string>((name, value) =>
            {
                return(Encoding.UTF8.GetString(dcrypt.Decrypt(Convert.FromBase64String(value))));
            });

            var decryptedConfig = ConfigurationParser.Parse <BaseSettings>(_settingsPath, ConfigurationTypeEnum.FileOnly, decryptHandler);

            if (decryptedConfig.Login.DcryptKey is null)
            {
                decryptedConfig.Login.DcryptKey = config.Login.DcryptKey;
            }

            decryptedConfig.LegacyHistory = LoadLegacyHistory();

            Save(decryptedConfig);

            return(decryptedConfig);
        }