Most of us don’t want other people to read our mail, which is why we use letters instead of postcards. Almost all information on the Internet is transmitted on the equivalent of postcards. Even if nobody is deliberately spying on you, electronic mail is frequently misdelivered. If you mistype a recipient’s address, your mail might get sent to a system administrator somewhere. It’s surprisingly easy for information you thought was confidential to be available to hundreds of thousands of people on the Internet.

Even data on your computer’s hard disk is surprisingly available to your coworkers, the people who clean your office, and anyone else who might have physical access to your computer. If you are considering leaving your current job, you probably wouldn’t feel comfortable leaving a copy of your résumé on your office computer; someone might find it.

To protect your information from prying or curious eyes, you need to take extra precautions. A common way to protect information is to encrypt it at the sending end and decrypt it at the receiving end. Encryption is the process of taking data, called plaintext , and mathematically transforming it into an unreadable mess, called ciphertext . Decryption takes the ciphertext and transforms it back into plaintext. The mathematical algorithm that performs the transformations is called a cipher . Figure 2.1 shows how this works.

Figure 2-1. Operation of a cipher

To protect data on a hard disk, you would encrypt it before writing ...

Get Java Cryptography now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.