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

Reveal

The 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 *** here

Code:

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 text

This 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 text

Code:

<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 :)