""" Configuration file for the EXE encryption system Contains security settings and system parameters """ import os from pathlib import Path # System configuration SYSTEM_CONFIG = { 'app_name': 'EXE Secure Wrapper', 'version': '2.0.0', 'company': 'Secure Software Solutions', 'contact': 'support@securesoft.com' } # Security settings SECURITY_CONFIG = { # Encryption settings 'key_length': 32, # bytes 'salt_length': 32, # bytes 'iterations': 100000, # PBKDF2 iterations 'hash_algorithm': 'sha256', 'xor_key': os.environ.get('EXE_WRAPPER_KEY', 'EXEWrapper#2024').encode(), # File validation 'min_file_size': 1024, # bytes 'magic_header': b'ENC_MAGIC', 'header_size': 512, # 配置头固定长度(字节) # License settings 'trial_days': 7, 'license_key_length': 20, 'license_format': 'XXXXX-XXXXX-XXXXX-XXXXX', } # Temporary file settings TEMP_CONFIG = { 'temp_prefix': 'sec_wrap_', 'max_temp_age': 3600, # seconds (1 hour) 'auto_cleanup': True, } # Database settings (会被嵌入到包装文件中) DATABASE_CONFIG = { 'mysql': { 'host': os.environ.get('DB_HOST', 'localhost'), 'port': int(os.environ.get('DB_PORT', 3306)), 'database': os.environ.get('DB_NAME', 'license_system'), 'user': os.environ.get('DB_USER', 'root'), 'password': os.environ.get('DB_PASSWORD', ''), 'charset': 'utf8mb4', 'connection_timeout': 30, 'ssl_disabled': True, }, 'sqlite': { 'filename': 'licenses_local.db', 'check_same_thread': False, } } # Logging configuration LOGGING_CONFIG = { 'level': 'INFO', 'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s', 'file_max_size': 10 * 1024 * 1024, # 10MB 'backup_count': 5, 'log_dir': 'logs', } # Validation settings VALIDATION_CONFIG = { 'check_internet': True, 'max_retries': 3, 'retry_delay': 1, # seconds 'timeout': 10, # seconds 'heartbeat_interval': 300, # seconds (5 minutes) } # Build paths BASE_DIR = Path(__file__).parent.absolute() CONFIG_DIR = BASE_DIR / "config" LOG_DIR = BASE_DIR / LOGGING_CONFIG['log_dir'] TEMP_DIR = BASE_DIR / "temp" # Ensure directories exist for directory in [LOG_DIR, TEMP_DIR, CONFIG_DIR]: directory.mkdir(exist_ok=True) def get_config_path(filename): """Get full path to configuration file""" return CONFIG_DIR / filename def get_temp_path(filename=None): """Get temporary file path""" if filename: return TEMP_DIR / filename return TEMP_DIR def get_log_path(filename): """Get log file path""" return LOG_DIR / filename