I am trying to add decrypt javascript and it is not working
var decrypedjs = "alert(\"test\")" //for example;
function start() {
decrypedjs
};
and the html
<button onclick="start()">started</button>
i have looked at so many sources and what i am finding is not really helpful or not working.
var newScript = document.createElement("script");
var inlineScript = document.createTextNode("alert('Hello World!');");
newScript.appendChild(inlineScript);
target.appendChild(newScript);
>Solution :
I’m not going to comment on any security point other than to not use eval with external sourced strings (post-, get parameters, etc), but you’re looking for the eval method:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
var decrypedjs = "alert(\"test\")" //for example;
function start() {
eval(decrypedjs);
};
start();