Search code examples
javascriptobfuscationreferenceerrorrot13

Reference Error when using ROT13 cipher to obfuscate email


I'm using this online tool to create the JavaScript code required to obfuscate an email address with an ROT13 cipher and it works fine, however I get the below JS ReferenceError when using it:

ReferenceError: eo is not defined

Here is the code I am using:

<span id="obf">
    <script>document.getElementById("obf").innerHTML="<n uers=\"znvygb:[email protected]\" >[email protected]</n>".replace(/[a-zA-Z]/g,function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);});document.body.appendChild(eo);</script>
    <noscript>[Enable JavaScript to see email]</noscript>
</span>

This bit of code at the end of the script appears to be the culprit:

document.body.appendChild(eo);

Any idea what the issue is?


Solution

  • Try this ... the last part of the script is just plain wrong:

    <span id="obf">
        <script>document.getElementById("obf").innerHTML="<n uers=\"znvygb:[email protected]\" >[email protected]</n>".replace(/[a-zA-Z]/g,function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);});</script>
        <noscript>[Enable JavaScript to see email]</noscript>
    </span>