|Đây là công cụ rất hưu ích để mã hóa và giải mã HTML/text/J-Script|
|Normal Text/HTML/J-Script (Select all🖐)||Escaped Text/HTML/J-Script (Select all✋)|
All I’m doing here is putting the escaped string in a set of quotes (important!), wrapping that inside the built-in unescape() method, and then wrapping that in a document.write() method. This might seem a little worthless, but you could hide an email address this way to prevent web crawlers from snagging your e-mail address from your webpage to use in mass spam e-mailings, yet allowing visitors to read it fine… Unless, of course, you actually like getting Viagra solicitations.
For instance, my fully escaped e-mail address would look like this to a web crawler:
… but would look like this to a visitor:
|Normal Text/HTML/J-Script (Select all👇)|
|Encoded Text/HTML/J-Script (Select all👇)|
- First, all the text is escaped.
- Then the script finds the Unicode values for each character in the string.
- Then the script adds whatever the Code Key drop-down box value is to each character’s Unicode value.
- Then the script derives characters based on the shifted Unicode values.
- The Code Key value is also embedded in the decoded text so the script knows how to properly decode the string again.
- Finally, it escapes the result one more time to remove any special characters. Now, the output looks totally foreign to someone who cannot un-shift Unicode values in their head.
The decode step <-- span=""> simply reverses the process.
Unfortunately, the browser does not have any built-in ability to handle the decoding, so we have to use a function for that. So, you have to escape the function that handles the decoding to hide that part, and have the browser write it to the document. You don’t really have to escape the decoding function, but it will make it that much harder for someone to figure out what’s going on. Then, the decoding function can be used to decode the rest of whatever content you have encoded. I’ll outline the steps below one-by-one to make this less confusing.
- Escape the decoding function. Before this function is escaped, it looks like this:
Once escaped, the function looks like this:
Anyway, now you have to make the browser write that part of the script to the page by wrapping it in the document.write() and unescape() methods like this:
- Now that you have the decoding function on the page, you can call it to decode whatever content you have encoded. Let’s say you had a script you wanted to protect; something like an image preloading script like this:
Once the script above is encoded using “code key” number 1, it looks like this:
Then, you decode the string and write it to the page by calling the dF() function (which was just unescaped and written to the page in the previous step) passing the string above like this:
So, to bring all this together, the following is what you would paste into your page:
I’ve highlighted the part that unescapes the decoder function in light yellow, and the part that decodes the preloading script and writes it to the page in light blue. You would just paste the whole section above into your page and the script would function perfectly just like it would if it were plain old English. Yes, it looks confusing, but that’s the point isn’t it? Oh, and one more thing: the whole string should appear on one line; you can not add forced line breaks.
The same thing is done if you want to encode a whole HTML page, except the encoded part of the string (light blue) could potentially be HUGE. The escaped function (light yellow) would not change however.
I’ve made a couple of wizards you can use for different purposes. You can achieve the same thing by using the escape/un-escape & encoder/decoder functions above, but these are specialized to take out some of the guesswork. Each of the links below will open a new window.
- HTML Page Encoder – Designed to encode your whole HTML page. You just enter your HTML sourcecode into one box, select the encoding scheme, and press the “encode” button. The output can be pasted directly into a blank page and saved as an HTML file.
The method this script uses to shift the Unicode values may be different from other similar encoding scripts you may find elsewhere on the net. My version simply adds the “Code Key” value to the Unicode value. Others may subtract, multiply, divide, square, etc a number to scramble the original text. No matter what, the method is very similar.
You can find a complete chart of all the UniCode values using the MS Windows charmap application.
Từ khóa: Công cụ – Tools, công cụ online, Tool, Công cụ, tool online.