Preventing unauthorized use of developers code

by GOKILAVANI 2014-02-15 09:39:17

*If we think people are stealing our scripts for use on their own sites then we should not implement in js.

*The user can view the code as JS is interpreted language.

*It is possible to hide code from naive users by placing it in externally linked js files.

*But this will not prevent borrowing the code.

*The code can be retrieved from browsers cache or download it using direct url.

*A partial solution to protect Js code is offered by code obfuscators.

*<font color=#FF00CC>Obfuscators read in JS</font>(or a web page) and <font color=#FF0000>output a functionally equivalent version of the code</font> that is scrambled (presumably) beyond recognition.

*Obfuscators are often included with crenches,but there are number of stand alone obfuscators are available on the internet.

<u>Sample code:</u>
js code:Input

var day=new Date().getDay();
switch (day)
{
case 0:
x="Today is Sunday";
break;
case 1:
x="Today is Monday";
break;
case 2:
x="Today is Tuesday";
break;
case 3:
x="Today is Wednesday";
break;
case 4:
x="Today is Thursday";
break;
case 5:
x="Today is Friday";
break;
case 6:
x="Today is Saturday";
break;
}

<u>Output(Obfuscated result)</u>

var _0x22cd=["x67x65x74x44x61x79","x54x6Fx64x61x79x20x69x73x20x53x75x6Ex64x61x79","x54x6Fx64x61x79x20x69x73x20x4Dx6Fx6Ex64x61x79","x54x6Fx64x61x79x20x69x73x20x54x75x65x73x64x61x79","x54x6Fx64x61x79x20x69x73x20x57x65x64x6Ex65x73x64x61x79","x54x6Fx64x61x79x20x69x73x20x54x68x75x72x73x64x61x79","x54x6Fx64x61x79x20x69x73x20x46x72x69x64x61x79","x54x6Fx64x61x79x20x69x73x20x53x61x74x75x72x64x61x79"];var day= new Date()[_0x22cd[0]]();switch(day){case 0:x=_0x22cd[1];break ;;case 1:x=_0x22cd[2];break ;;case 2:x=_0x22cd[3];break ;;case 3:x=_0x22cd[4];break ;;case 4:x=_0x22cd[5];break ;;case 5:x=_0x22cd[6];break ;;case 6:x=_0x22cd[7];break ;;} ;
502
like
0
dislike
0
mail
flag

You must LOGIN to add comments