Cryptography la versíon española la version française

using JavaScript


I hear you. What do I do with all this stuff? Encryption is simple in concept (only the good guys can read your message), but devilish in the details. Here's a simple set of worked examples which illustrate some of the ways you can use JavaScrypt to protect your privacy. These examples open an auxiliary browser window in which various JavaScrypt components are demonstrated. Please use the buttons in this page exclusively; pressing the buttons in the popped-up window may confuse the sequencing of the example.

Crypto-folk usually couch their examples in terms of messages sent between the virtuous "Alice" and "Bob", who wish to avoid them being intercepted and read by the nefarious "Eve". I'll follow that convention here, so let's join Alice and Bob as they hatch a plot.

Encrypt a Message

We'll begin by encrypting a short message from Alice at headquarters to Bob in the field. First, Alice loads the JavaScript page into her browser. Press the button below to launch JavaScrypt in a new window.

Alice and Bob have decided to use a "book code" for their encryption keys. When they last met face to face, they agreed to obtain the keys for their encrypted messages from an innocuous science fiction novel. Each time Alice or Bob sends a message, they pick a page of the book and line number on the page at random, then use whatever text appears on that line as the encryption key. The line, once used, is crossed out so it will never inadvertently be reused. This way, no two messages are ever sent with the same key, and each key, composed of an entire line of English text, is sufficiently long as to be difficult to guess. (Book codes are far from optimal; later on we'll discuss more secure alternatives. At the moment, we're concerned with the mechanics of encryption and decryption, not details of key generation and distribution.)

This time, by throwing dice or whatever, Alice has chosen line 28 on page 172 of the book, which reads:

"serious hacker you don't let flames bother you. Instead"

This is the key for the message, so Alice types it into the Key box on the JavaScrypt page.
Press the button below to enter the key into the box.

Next, Alice enters the text of her message to Bob in the The Text box. "The Text" refers to the original message before encryption into "The Cipher Text", or recovered from the Cipher Text by decryption.
Press the button below to enter Alice's message into the The Text box.

"BAGPIPE FJORD" is the meaningless code name for the operation she's giving Bob the go-ahead to proceed with; later on we'll see how to generate such names automatically.
Please press the button below to encrypt the The Text with The Key.

Alice can now copy the encrypted message from the Cipher Text box (pressing the Select button below it selects the entire cipher text) and paste it into an E-mail message to Bob. Before the cipher text, Alice will write the page and line number she used as the key. If Eve intercepts the E-mail, this won't do her any good unless she's somehow learned which book Alice and Bob are using for their keys.

Decrypt a Message

Now we change the scene from Alice's air conditioned office to Bob's more austere accommodations in the field. After receiving Alice's message, including the page and line numbers at the start, he loads a copy of JavaScrypt into his own browser, as you can do by pressing the following button.

Bob begins by pasting Alice's message into the initially empty Cipher Text box. Note that the message contains Alice's page and line notation, "172/28". JavaScrypt ignores any text before the start of the encrypted message, so Bob hasn't bothered to remove the key annotation from Alice's message.

Bob then proceeds to dig out his copy of book, turns to page 172 and counts down 28 lines to find the key, which he types into the Key box at the top of the JavaScrypt page. Press the button below to enter the key.

Now Bob need only press the Decrypt button below the Cipher Text box to decrypt the message. Alice's original text will now appear in the Plain Text box.

To recover the Plain Text, the decryption key must be identical to that used to encrypt the message.

adapted by Rafal Swiecki, p. eng. email
November, 2004
This document is in the public domain.

Click Navigation Mining Search Engine Rafal Swiecki, p. eng. Mining Directory Mining Placer Mining Exploration Mining Tools Business with Mining Exchange Mining Weather Secure eMail