How to use decode jquery script

≯℡__Kan透↙ 提交于 2019-12-06 21:48:39

You can use window.btoa(string) to encode any string, and window.atob(string) to decode it.

In your case

window.atob('ICAgIHZhciB3aW5kb3dXaWR0aCA9ICQoIHdpbmRvdyApLndpZHRoKCk7CiAgICB2YXIgd2luZG93SGVpZ2h0ID0gJCggd2luZG93ICkuaGVpZ2h0KCk7CiAgICB2YXIgZG9jdW1lbnRXaWR0aCA9ICQoIGRvY3VtZW50ICkud2lkdGgoKTsKICAgIHZhciBkb2N1bWVudEhlaWdodCA9ICQoIGRvY3VtZW50ICkuaGVpZ2h0KCk7Cg');

Returns

"   var windowWidth = $( window ).width();
    var windowHeight = $( window ).height();
    var documentWidth = $( document ).width();
    var documentHeight = $( document ).height();
"

Which is just one string with four linebreaks.

If you want to use them to declare variables in your current scope, one way would be to split by linebreaks and then eval each line, but using eval is a bad idea in general.

I suggest you reconsider what do you want to achieve and find a safer method.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!