Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
206 views
in Technique[技术] by (71.8m points)

javascript - How to hide links in HTML source code while using browser to get source code view?

Something like this <a href="url">...</a> in an HTML page can be get in the browser source code view when press F12. A HTML page exposes some interfaces and url in the browser source code view. Someone takes advantage of this to get the resource of urls and download resource without paying. I wonder how to encrypt the urls so that no one can download resources without paying. I search for this question. I get the following solutions, but I think maybe they are not secure enough. I find that disabling some key such as F12, Shift+F10 can be a solution. The other way is to encrypting the HTML source code. The method I find is to use escape. I am new to JavaScript. I wonder how to use some crypto encryption methods, such as AES, MD5, to do this work. Thanks for your help.

question from:https://stackoverflow.com/questions/65884245/how-to-hide-links-in-html-source-code-while-using-browser-to-get-source-code-vie

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your approach to this is entirely wrong.

If you don't want the user to have something, then just don't give it to them. Don't give it to them wrapped in some form of encryption.

If you don't want the link to work without the user paying then use server side code which has logic along the lines of:

if (!userHasPaid()) {
    redirect(sales_page);
    exit;
}
provideDownload();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...