My Goal: I am trying to encrypt .js files into .jse and decrypt only when it is running (obfuscate nodejs code).
var ffi = require('ffi'); //libpcrypt.so is a library to encrypt and decrypt files var crypt = ffi.Library('./libpcrypt', { 'decrypt' : [ 'string', ['string', 'string']] }); require.extensions[".jse"] = function (module) { module.exports = (crypt.decrypt(module.filename, 'out')); }; console.log(require('./routes.jse'));
I know, with cosole.log() source code can be printed out.
Problem: Decrypted code is a plain string, I am not able to convert it into a valid javascript object for exports. Is there a way to export the code string I decrypted?