2
eval("Encryption={Load:function(enc){var id=enc.split('/z');var e=[id[0],id[2]];id=toNumber(string.reverse(id[1]));enc=e.join('');e=enc.substring(1).split('/');var fin='';console.log(id);for(var CN=0;CN<e.length;CN++){fin+=string.char(toNumber(e[CN])/id);}eval(fin);}};");

It's all on one line because adding new lines into the string (even if I just put \n), causes another error.

When I run this, I get the error, "Uncaught SyntaxError: Unexpected token ILLEGAL"

I can't understand why. I did start chopping off pieces of code, and found the error comes right after

e=enc.substring(1).split('/');

is added.

So if I remove everything in Encryption's Load function including that, it will work. Though I need all of the function.

And I did Google it, and nothing seemed to fit what I was looking for.

2
  • 5
    That's horrible. Who wrote this code? What are you trying to achieve with eval? Commented Dec 27, 2013 at 15:26
  • 3
    I don't get that error when I try your code. I suspect that you may have a stray invisible unicode character somewhere in the string. Commented Dec 27, 2013 at 15:27

1 Answer 1

4

You had an invalid character in the initial code you posted which you have fixed in your edit:

enter image description here

This works fine:

eval("Encryption={Load:function(enc){var id=enc.split('/z');var e=[id[0],id[2]];id=toNumber(string.reverse(id[1]));enc=e.join('');e=enc.substring(1).split('/');var fin='';console.log(id);for(var CN=0;CN<e.length;CN++){fin+=string.char(toNumber(e[CN])/id);}eval(fin);}};");

as it can be seen from this this jsfiddle.

Sign up to request clarification or add additional context in comments.

2 Comments

I compared the two strings between this one, and the old one and they both look the same. Though, this one loads, and the other one (the original one) doesn't. In Pointy's comment he said that I may have a stray invisible unicode character, how would I have found that, for future reference?
Just do as I did in this case to answer your question. Copy paste the code in a decent code editor (I used jsfiddle.net) in this particular case, then indent it as a normal developer would write code and the obvious unicode character will bump into your eye. Isn't it immediately obvious from my screenshot? Of course if you keep your code as a single line, then it's much harder to detect those characters. They usually come when people copy paste form the internet on some blogs which have poorly written code highlighters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.