Encoding/Decoding Javascript in Nashorn -


i use technique described here: http://scriptasylum.com/tutorials/encode-decode.html

in nutshell, 1 has javascript file looks this, actual javascript encoded:

document.write( unescape( 'escaped string' ) ); df('encoded javascript'); 

i want run same .js module under nashorn, nashorn not have document object. therefore, can not document.write().

note: known technique bypassed , people modest technical ability can still @ actual code. use case not require strong security not concern. said, please consider answers on why 1 should not off topic. thanks.

basically, code breaks down 2 parts:

  1. un-obfuscate string via unescape.

  2. write string out via document.write.

it sounds want use string directly reason.

you have @ least 2 options:

  1. you can provide document object scripting engine write method accepts string. can like. (or substitute document.write before evaluating string function want called.)

  2. remove document.write( , corresponding ) @ end , have engine evaluate string , hand directly result of scriptengine#eval.

either way, you'll end string can with.


Comments