-1

Help me out!

I would like to ask how to implement my Obfuscated code?

heres my sample code

var accessToken = $('#access_token').val();
var myapp = angular.module("loginApp", []);


myapp.controller("loginCtrl", function ($scope, $http) {
    $scope.log_username = '';
    $scope.log_password = '';
    $scope.loginfirst = $("#reqerr").val();

sample code obfuscated code

eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('3 4=$(\'#8\').2();3 1=7.6("5",[]);1.g("9",e($0,$f){$0.d=\'\';$0.c=\'\';$0.a=$("#b").2();',17,17,'scope|myapp|val|var|accessToken|loginApp|module|angular|access_token|loginCtrl|loginfirst|reqerr|log_password|log_username|function|http|controller'.split('|'),0,{}))

my problem is how do i implement it? i tried to replace my sample code with obfuscated code, i got an error, and i have no idea on how should i implement it?

PS dont mind the code above , its just a sample..

5
  • 4
    What error do you get? And, above all, what do you mean with "implement my obfuscated code"? Commented Oct 1, 2014 at 9:02
  • missing ";" on the first line like that.. Commented Oct 1, 2014 at 9:03
  • @AlexisKing Don't mind the code above it just a sample.. i just want to know how should i implement my obfuscated code to my project/javasacript.. Commented Oct 1, 2014 at 9:05
  • 1
    "Don't". Obfuscated code is just hard to work with an inefficient. Commented Oct 1, 2014 at 9:10
  • you need add () brackets around function declaration, now you have function(...){...}(...) but you need (function(...){...})(...) Commented Oct 1, 2014 at 9:14

1 Answer 1

-2

You need a special tool like google's closure compiler, but before that you need to properly inline annotate your services like so...

myapp.controller("loginCtrl", ["$scope", "$http", function ($scope, $http) {
    ....
}])

This statement clarifies why, and is correct.

"When minifying, variable names are changed to save space. That means the $scope variable could be renamed to 'a', which interferes with AngularJS' dependency injection. Annotating the services allows AngularJS to keep the relationship between minified variables and the service they represent" - bob esponja

Then follow the steps below:

Step 1) Download http://dl.google.com/closure-compiler/compiler-latest.zip

Step 2) run (you need to install java's JRE or JDK)

java -jar compiler.jar --js hello.js --js_output_file hello-compiled.js
Sign up to request clarification or add additional context in comments.

13 Comments

Don't mind the code above it just a sample.. i just want to know how should i implement my obfuscated code to my project/javasacript..
This really should just be a comment, not an answer.
happy to have helped... you're welcome... =)
Link-only answers aren't considered "Okay" on SO.
and is more easily readable on answer space --
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.