Skip to content

feat: add numbersToHexadecimal option to control number to hex conver… #1319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jbetala7
Copy link

@jbetala7 jbetala7 commented Aug 7, 2025

🎯 Purpose

Resolves #1317 - Adds option to prevent automatic conversion of numbers to hexadecimal format.

📋 Changes

  • ✅ Added numbersToHexadecimal boolean option (default: true)
  • ✅ Updated NumberLiteralTransformer to respect the new option
  • ✅ Added CLI support with --numbers-to-hexadecimal flag
  • ✅ Updated all configuration presets and interfaces
  • ✅ Added comprehensive test coverage
  • ✅ Updated README documentation with examples

🔄 Behavior

  • Default (true): Maintains existing behavior (backward compatible)
  • New (false): Keeps numbers in decimal format

🧪 Testing

Added test cases covering both scenarios:

  • numbersToHexadecimal: true converts to hex
  • numbersToHexadecimal: false preserves decimal

📚 Documentation

  • Updated README with option description and examples
  • Added CLI option documentation
  • Updated default options section

🔧 Usage Examples

// JavaScript API
JavaScriptObfuscator.obfuscate(code, {
    numbersToHexadecimal: false
});

// CLI
javascript-obfuscator input.js --numbers-to-hexadecimal false

This solution will help not just @acemtp, but any other users who prefer to keep their numbers in decimal format for readability or specific requirements!

…sion

- Add new numbersToHexadecimal option (default: true) to control whether numbers are converted to hexadecimal format
- When true, numbers like 1000 are converted to 0x3e8
- When false, numbers remain in their original decimal format
- Update CLI interface to support --numbers-to-hexadecimal flag
- Add comprehensive documentation with examples
- Update all relevant presets and tests
- Fixes issue where users couldn't disable number to hex conversion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

how to not convert numbers into hexadecimal?
1 participant