/// <summary>
        /// Starts the obfuscation process based on a ObfuscationConfig file, generated with the
        /// PHP Obfuscator GUI.
        /// </summary>
        /// <param name="config">Config class generated by the PHP Obfuscator GUI</param>
        /// <param name="async">Flag indicating whether to run this process asynchronously. If true, this function will
        /// return as soon as the file copy is done. False will result in the function returning only after all obfuscation
        /// has completed. </param>
        public void Start(ObfuscationConfig config, bool async)
        {
            _config = config;
            if (null == _config)
            {
                return;
            }

            this.ExcludedVariables  = new List <string>(_config.ExcludeVariables);
            this.ExcludedFunctions  = new List <string>(_config.ExcludeFunctions);
            this.RemoveWhitespace   = _config.RemoveWhitespace;
            this.ObfuscateFunctions = _config.RenameFunctions;
            this.ObfuscateVariables = _config.RenameVariables;

            Start(_config.SourceDir, _config.TargetDir, new List <string>(_config.FilesToObfuscate), true);
        }
Exemple #2
0
        /// <summary>
        /// Generates a configuation file that can be reloaded in subsequent executions of this tool, or 
        /// can be used to run the command line version of this tool.
        /// </summary>
        /// <returns></returns>
        private Obfuscation.ObfuscationConfig GenerateConfig()
        {
            Obfuscation.ObfuscationConfig config = new ObfuscationConfig();

            config.SourceDir = sourceDirectory.Text;
            config.TargetDir = targetDirectory.Text;

            config.RemoveWhitespace = removeWhitespace.Checked;
            config.RenameVariables = obfuscateVariableNames.Checked;
            config.RenameFunctions = obfuscateFunctionNames.Checked;

            List<string> excludeFunctions = new List<string>(excludeFunctionsList.CheckedItems.Count);
            foreach (string item in excludeFunctionsList.CheckedItems)
                excludeFunctions.Add(item);

            config.ExcludeFunctions = excludeFunctions.ToArray();

            List<string> excludeVariables = new List<string>(excludeVariablesList.CheckedItems.Count);
            foreach (string item in excludeVariablesList.CheckedItems)
                excludeVariables.Add(item);

            config.ExcludeVariables = excludeVariables.ToArray();

            List<string> filesToObfuscate = new List<string>(obfuscateList.CheckedItems.Count);

            foreach (string file in obfuscateList.CheckedItems)
            {
                filesToObfuscate.Add(file);
            }
            config.FilesToObfuscate = filesToObfuscate.ToArray();

            return config;

        }
Exemple #3
0
        /// <summary>
        /// Starts the obfuscation process based on a ObfuscationConfig file, generated with the 
        /// PHP Obfuscator GUI. 
        /// </summary>
        /// <param name="config">Config class generated by the PHP Obfuscator GUI</param>
        /// <param name="async">Flag indicating whether to run this process asynchronously. If true, this function will 
        /// return as soon as the file copy is done. False will result in the function returning only after all obfuscation
        /// has completed. </param>
        public void Start(ObfuscationConfig config, bool async)
        {
            _config = config;
            if (null == _config)
                return;

            this.ExcludedVariables = new List<string>(_config.ExcludeVariables);
            this.ExcludedFunctions = new List<string>(_config.ExcludeFunctions);
            this.RemoveWhitespace = _config.RemoveWhitespace;
            this.ObfuscateFunctions = _config.RenameFunctions;
            this.ObfuscateVariables = _config.RenameVariables;

            Start(_config.SourceDir, _config.TargetDir, new List<string>(_config.FilesToObfuscate), true);
        }