Is there a way i can encrypt or scramble a certain text so it cannot from browser view source. For example if i have a video id 117 showing in the view source html, and i want to encrypt that or make it difficult to read, is this possible.
Share
If you want the video link to be useless except in the context of the page you’ve just returned to the client, you can do something with server-side code.
The usual thing is a one-time or limited-duration ID that’s generated specifically for the page. For instance,
ab23jjgk23098jajzklwravmzzxwrpo2q3476asrather than117. On the server, you have a table mapping these one-time / limited-time IDs to the real ID. In the table you can also link the ID to the IP address of the request for the page, and then only respect the ID if the request for the video comes from that same IP address. It’s important that the IDs not actually contain the video ID (obfuscated or not), hence the server-side table, and that they be effectively random.I say “table,” but of course it needn’t really be a database table. It could be anything that lets you store key/value pairs, such as
memcached.Update based on your comment below.
Without server-side mapping (database, session,
memcached, etc.), all you can do is some obfuscation, and it’s going to be easy for anyone semi-technical to break. If what you’re outputting is a URL (in a link, in anobjecttag, etc.), you can use URL-encoding to make it hard to read, e.g.:…which, when clicked, will call your
video.phpfile with the parametersnonsense=foo,id=117, andrubbish=bar(that’s what’s encoded in the query string, using percent-encoded entities). But again, although it might deter non-technical people, technical people won’t be fazed.