开发者

How to encrypt HTML source code output using PHP

开发者 https://www.devze.com 2022-12-30 12:20 出处:网络
I want to deter novice users from seeing the source code. I have a php code tha开发者_Python百科t generates a html page.

I want to deter novice users from seeing the source code. I have a php code tha开发者_Python百科t generates a html page.

edit1: I came across a simple tool which encrypted html code into %C%D%F but which worked with the browser just fine.


You can't encrypt the HTML output that is sent to your users. They wouldn't be able to load the web page if you did.

If you're concerned about them seeing the PHP code, you don't have to worry about that. They'll never see the PHP code - it's processed by the server and turned into HTML before sending to the client.


While, as @Jeff said, you can't encrypt your HTML output, you can obfuscated it to make it more difficult for a human to understand. Here is a link to a free product that does just that.


See: http://farhadi.ir/works/rc4

Two simple libraries allow you to encode in PHP and decode in Javascript. In your output simply set up the HTML skeleton and then run the decrypt with the key and encrypted string in a document.ready function and populate the <body> tag with the product of decryption.

Of course, this only works with Javascript enabled. Otherwise the use won't see anything useful. You're also passing your secret key in the clear which is fine since you're only trying to prevent "novice" users from accessing your source code. I also don't think it will really help you out that much in preventing someone from grabbing an image from your site. You're much better off working with .htaccess to do that. Check out http://bignosebird.com/apache/a13.shtml or Google


I don't think you can encrypt HTML. It has to be interpreted by the client browser, it wouldn't work if you used a different language


You should use javascript's escape/unescape functions instead so that it is harder for humans to decipher but not the browser.


You could be ultimately cheeky and use this: http://www.dynamicdrive.com/dynamicindex9/encrypter.htm

It basically encrypted your HTML code into a javascript document.write line.

Not really encryption, but will deter over half the people browsing the source.

Enjoi.

0

精彩评论

暂无评论...
验证码 换一张
取 消