Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Encrypt jsp on right click view source  RSS feed

 
Suchira Gharde
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My requirement is I have to show html in encrypted format when i right click view source how can I do that without using any tool?

Please reply asap.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
encrypted format, why ?? You wished to not to show the HTML source to the user?
If yes, the simple solution will be using JavaScript, just disable the right click OR write down your own JS to encrypt the HTML source, which is I don't know how?

And welcome to JR.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While googling your requirement, I found this link:
http://www.antssoft.com/htmlprotector/index.htm
Hope this will serve your purpose.

And interestingly they are not using this s/w for their own web pages ;)
 
Suchira Gharde
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My requirement is not to disable the right click but to show the html in encrypted format once user clicks view source.How can I write that in jsp can anybody provide me with some sample code?
 
Suchira Gharde
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to write some code in javascript so that the html code is displayed in encrypted format when user right clicks view source.

Can anybody help me out with some sample js code?
 
Hany Shafik
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it is impossible, the user will always be able to view the HTML source. Even if you tried to disable the right click, there will be so many ways to bypass it.
Also if you managed to encrypt it using JavaScript, anyone who is planning on stealing the content of your web page can easily use a TCP/IP proxy that monitor the HTTP traffic to view your code.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This can't be done, since the browser must have access to the actual HTML/JavaScript source code. And you should not try to disable UI elements, either: InterfaceDesignersRule1.

What is the reason for wanting to do this? Surely, if the browser is allowed to display to a user what a web page contains then there can't be anything in it that needs to be protected from the user?
 
Suchira Gharde
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually its been required to protect the source code from being viewed by any one.Its sort of website security?Is there any sample javascript code by virtue I can do this?
 
Moojid Hamid
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The browser's "view source" does not show the JSP source code, if that is what you are worried about. It only shows the rendered HTML.
 
Suchira Gharde
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But if user right click and then view source then the whole source is visible so I basically want to show html in encrypted form if user right click and view source.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again - *why* is it required? What do you hope to achieve by doing this? If you tell us the reasoning, we may be able to suggest alternatives.
 
Suchira Gharde
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because there are some sensitive information which is being displayed in the website which an anonymous user should not see when he right clicks view source.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is there sensitive information in a page that's being displayed to unauthenticated users? That's the real problem that you should be addressing.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Disabling the right click, is not the right solution, why ? see below comments
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So far, the best possible solution to your problem, is disabling the right click

That is not a solution. Various browsers (such as Firefox) have options that prevent the page from doing this.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:
So far, the best possible solution to your problem, is disabling the right click

That is not a solution. Various browsers (such as Firefox) have options that prevent the page from doing this.

Well, I found many JS links on the internet, but not a single developer pointed out this FF option. Also, even If we success in disabling the mouse click, anyone can save the HTML file and view source.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found many JS links on the internet, but not a single developer pointed out this FF option.

Just goes to show that JavaRanch is a better place to get information than other random forums elsewhere...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!