JavaScript Encryption and Decryption 2.0 The JavaScript decryption code is developed by Vincent Cheung. Encryption/Decryption ...
JavaScript Encryption and Decryption 2.0
The JavaScript decryption code is developed by Vincent Cheung.
JavaScript Encryption and Decryption Features
Encrypt your webpage or blog
- Keep your information hidden from others, even the government!
- Put encryption on any webpage
- Decrypt right in your own webpage
- Show encrypted text (the password is: decrypt)
- There are lots of different ways to use this on your own site
Fast and easy
- It just takes a little bit of copying and pasting to add encryption to any webpage
- Decrypting is as simple as clicking a link and entering the password
- Tested in Internet Explorer, Firefox, Chrome, Safari, Opera and on Windows, Mac OS X, and Linux
Secure
- The encryption used is 256-bit AES, the standard used by the US Government
- Unlike regular password protection, everything is done locally in the browser using JavaScript, so your unencrypted information is never on the internet, not even on the server!
- The encrypted text is safe as long as you keep the key secret. Do not lose the key. If you do, no one can help you!
Free with no catches
- Completely free with no ads, viruses, spyware, stds, trial periods, or watermarks
- No backdoors (not even I can break the encryption to read your encrypted information!)
- Ok, one catch, do not use this if encryption is illegal in your country or if you plan to use this for illegal purposes, and I am not responsible for anything you do with this
Instructions
To put encrypted text in your own site:- Add the decryption JavaScript code (see below)
-
Encrypt your text on the
encryption page
- Type the password for the encrypted text in the Key box (be sure to remember the key!)
- Enter whatever you want to encrypt in the Plain Text box
- Click Encrypt
- Copy and paste the code in the HTML Code box into your website or blog
The JavaScript decryption code
Between the<head> and </head> tags in the html code of your webpage, add the following:
<script type="text/javascript" src="http://www.vincentcheung.ca/jsencryption/jsencryption.js"></script>
Encrypted text and decryption link
This is the basic code to use in the body of the html code of your webpage to do the decryption:
<div id=" uniqueID" title=" encrypted text">
<a href="javascript:decryptText(' uniqueID')">Show encrypted text</a>
</div>
encrypted text is the encrypted text generated from the encryption/decryption page.
uniqueID is a unique name for the element, which is automatically generated by the encryption/decryption page in the sample code. This can be anything that you want, but do not put your key here because it is visible to everyone.
The decryptText JavaScript function gets the encrypted text from the title of the element with the id uniqueID. Once decrypted, the contents of the element are replaced with the decrypted text.
The two uniqueID's must be exactly the same, otherwise the code will not work.
See the examples page to see this in action and for different uses.
Advanced options
The decryptText function can accept an array of element id's and it will decrypt each of them. The encrypted text in each of these element id's can be encrypted with the same or different keys.You can change the message in the dialog box that asks for the key by providing the desired message as a second parameter, eg. decryptText('uniqueID', 'Enter the password:')
Instead of the fancy dialog box, you can use the standard JavaScript dialog box to request the key by doing this:
decryptText('uniqueID', null, true) or decryptText('uniqueID', 'Enter the key:', true)
One word of caution is that IE7 blocks the regular JavaScript dialog box and you have to click the pop-up message to allow the dialog to show.
Bookmarklets
Drag these to the bookmark toolbar:Encrypt
Decrypt
These bookmarklets provide a quick shortcut to the encryption/decryption page and automatically fills in the plain or encrypted text fields with the selected text on the page that you are currently on.
Examples
The decryption key for the examples below is: the key
Example 1: Basic version
Code:
<div id=" uniqueID" title=" encrypted text">
<a href="javascript:decryptText(' uniqueID')">Show encrypted text</a>
</div>
Plain text:
Hello World!
Example 2: Hidden image and link
Code:
<div id=" uniqueID" title=" encrypted text">
<a href="javascript:decryptText(' uniqueID')">Show encrypted info</a>
</div>
Plain text:
<a href="http://www.vincentcheung.ca/jsencryption/"><img src="img/JSEncryptionLogo150.png" /></a><br />
<a href="http://www.vincentcheung.ca/jsencryption/">JavaScript Encryption</a>
Example 3: Inline text
RevealThe secret...
Code:
<a href="javascript:decryptText(' uniqueID')">Reveal</a>
<br />
<br />
The secret... <span id=" uniqueID" title=" encrypted text"></span>
Plain text:
has been revealed!
Example 4: Hidden text
There is *** hereCode:
There is <span id=" uniqueID" title=" encrypted text">
<a href="javascript:decryptText(' uniqueID')">***</a></span> here
Plain text:
hidden text
Example 5: Hide your email address from spammers
Email address: Show email address (password: the key)Code:
Email address: <span id=" uniqueID" title=" encrypted text"><a href="javascript:decryptText(' uniqueID', 'Enter password:')">Show email address</a> (password: the key)</span>
Plain text:
<a href="mailto:***">***</a>
Example 6: Multiple encryptions
Decrypt textThis is cool
Code:
<a href="javascript:decryptText([' uniqueID1', ' uniqueID2'])">Decrypt text</a>
<br />
<br />
This is <span id=" uniqueID1" title=" encrypted text 1"></span>cool<span id=" uniqueID2" title=" encrypted text 2"></span>
Plain text:
<span style="color:red">really</span> and <span style="color:red">!!!</span>
Example 7: More than 1 key (the second key is: the second key)
Decrypt*** went ***
Code:
<a href="javascript:decryptText([' uniqueID1', ' uniqueID2'], 'Enter one of the decryption keys:')">Decrypt</a>
<br />
<br />
<span id=" uniqueID1" title=" encrypted text 1">***</span> went <span id=" uniqueID2" title=" encrypted text 2">***</span>
Plain text:
"Jack and Jill" (encrypted with one key) and "up the hill" (encrypted with the second key)
Example 8: Big example (the second key is: the second key)
Show encrypted textCode:
<a href="javascript:decryptText([' uniqueID1', ' uniqueID2'])">Show encrypted text</a>
<br />
<div id=" uniqueID1" title=" encrypted text 1"></div>
<div id=" uniqueID2" title=" encrypted text 2"></div>
<div class="clear"></div>
Plain text:
<div style="float:left; width: 48%">Lots of text</div> (encrypted with one key)
<div style="float:right; width: 48%">Lots more text</div> (encrypted with the second key)
Example 9: My personal blog
Sometimes I use encryption on my personal blog to keep things hidden from prying eyes. Most of my blog can be viewed by anyone, but every once in a while, I want to write about something that I don't want certain people to read.I give the key to people that I trust so they can read the encrypted posts. I use several different keys for my posts and different people have different keys.
These are my encrypted blog posts. No, you may not have the key :)
Disclaimer
Disclaimer: Do not use this if encryption is illegal in your country or if you plan to use this for illegal purposes.
This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
COMMENTS