Socket
Socket
Sign inDemoInstall

js-obfuscator

Package Overview
Dependencies
13
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    js-obfuscator

Obfuscate JavaScript files via javascriptobfuscator.com. This is also a Grunt plugin.


Version published
Maintainers
1
Created

Readme

Source

js-obfuscator

Obfuscate JavaScript files via javascriptobfuscator.com. This is also a Grunt plugin.

Getting Started

This plugin requires Grunt ~0.4.0

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install js-obfuscator --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('js-obfuscator');

Call

var jsObfuscator = require('js-obfuscator');
jsObfuscator ( <string> input [, <object> options ] )

Returns: a Q promise.

Options

keepLinefeeds

Type: Boolean Default: false

keepIndentations

Type: Boolean Default: false

encodeStrings

Type: Boolean Default: true

encodeNumbers

Type: Boolean Default: true

moveStrings

Type: Boolean Default: true

replaceNames

Type: Boolean Default: true

variableExclusions

Type: Array Default: [ '^_get_', '^_set_', '^_mtd_' ]

concurrency (for Grunt plugin only)

Type: Number Default: 2 Range: 1 - 99

Examples

Grunt

grunt.initConfig({
  jsObfuscate: {
    test: {
      options: {
        concurrency: 2,
        keepLinefeeds: false,
        keepIndentations: false,
        encodeStrings: true,
        encodeNumbers: true,
        moveStrings: true,
        replaceNames: true,
        variableExclusions: [ '^_get_', '^_set_', '^_mtd_' ]
      },
      files: {
        'dest/dest.js': [
          'src/src1.js',
          'src/src2.js'
        ]
      }
    }
  }
});

Call

var jsObfuscator = require('js-obfuscator');

var script = 'Array.prototype.diff = function(a) {' +
'  return this.filter(function(i) {return a.indexOf(i) === -1;});' +
'};';

var options = {
  keepLinefeeds:      true,
  keepIndentations:   true,
  encodeStrings:      true,
  encodeNumbers:      true,
  moveStrings:        true,
  replaceNames:       true,
  variableExclusions: [ '^_get_', '^_set_', '^_mtd_' ]
};

jsObfuscator(script, options).then(function(obfuscated) {
  console.log(obfuscated);
}, function(err) {
  console.error(err);
});

/*
var _0xa3c9=["\x64\x69\x66\x66","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65",
"\x69\x6E\x64\x65\x78\x4F\x66","\x66\x69\x6C\x74\x65\x72"]
Array[_0xa3c9[1]][_0xa3c9[0]]=function (_0x4068x1)
{
  return this[_0xa3c9[3]](function (_0x4068x2)
  {
    return _0x4068x1[_0xa3c9[2]](_0x4068x2)===-1;
  }
  );
}
;
*/

Developer

Keywords

FAQs

Last updated on 24 Jun 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc