js file
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)
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.
沒有留言:
張貼留言