What is cryptography? How algorithms keep information secret and safe

Public keys, private keys, and hash functions make the secure internet possible.

5 cryptography and data protection

Credit: Getty Images

Cryptography definition

Cryptography is the art of keeping information secure by transforming it into form that unintended recipients cannot understand. In cryptography, an original human readable message, referred to as plaintext, is changed by means of an algorithm, or series of mathematical operations, into something that to an uninformed observer would look like gibberish; this gibberish is called ciphertext.

Cryptographic systems require some method for the intended recipient to be able to make use of the encrypted message—usually, though not always, by transforming the ciphertext back into plaintext.

Cryptography vs. cryptology vs. encryption

Before we move into the meat of this article, let’s define a couple terms related to cryptography. The syllable crypt may make you think of tombs, but it comes from a Greek word that means “hidden” or “secret.” Cryptography literally means “secret writing.” Cryptology, meanwhile, means something like “knowledge of secrecy”; if cryptography is the practice of writing secret messages, then cryptology is the theory, although the two words are often used interchangeably. Encryption—“making secret”—is what we call the process of turning plaintext into ciphertext Encryption is an important part of cryptography, but doesn’t encompass the entire science. Its opposite is decryption.

One important aspect of the encryption process is that it almost always involves both an algorithm and a key. A key is just another piece of information, almost always a number, that specifies how the algorithm is applied to the plaintext in order to encrypt it. In a secure cryptographic system, even if you know the method by which some message is encrypted, it should be difficult or impossible to decrypt without that key. Keep algorithms and keys in your mind, because they’ll be important as we move on.

History of cryptography

This is all very abstract, and a good way to understand the specifics of what we’re talking about is to look at one of the earliest known forms of cryptography. It’s known as the Caesar cipher, because Julius Caesar used it for his confidential correspondence; as his biographer Suetonius described it, “if he had anything confidential to say, he wrote it in cipher, that is, by so changing the order of the letters of the alphabet … If anyone wishes to decipher these, and get at their meaning, he must substitute the fourth letter of the alphabet, namely D, for A, and so with the others.”

Suetonius’s description can be broken down into the two cryptographic elements we’ve discussed, the algorithm and the key. The algorithm here is simple: each letter is replaced by another letter from later in the alphabet. The key is how many letters later in the alphabet you need to go to create your ciphertext. It’s three in the version of the cipher Suetonius describes, but obviously other variations are possible—with a key of four, A would become E, for instance.

A few things should be clear from this example. Encryption like this offers a fairly simple way to secretly send any message you like. Contrast that with a system of code phrases where, say, “Let’s order pizza” means “I’m going to invade Gaul.” To translate that sort of code, people at both ends of the communication chain would need a book of code phrases, and you’d have no way to encode new phrases you hadn’t thought of in advance. With the Caesar cipher, you can encrypt any message you can think of. The tricky part is that everyone communicating needs to know the algorithm and the key in advance, though it’s much easier to safely pass on and keep that information than it would be with a complex code book.

The Caesar cipher is what’s known as a substitution cipher, because each letter is substituted with another one; other variations on this, then, would substitute letter blocks or whole words. For most of history, cryptography consisted of various substitution ciphers deployed to keep government and military communications secure. Medieval Arab mathematicians pushed the science forward, particularly the art of decryption—once researchers realized that certain letters in a given language are more common than others, it becomes easier to recognize patterns, for instance. But most pre-modern encryption is incredibly simple by modern standards, for the obvious reason that, before the advent of computers, it was difficult to perform mathematical transformations quickly enough to make encryption or decryption worthwhile.

In fact, the development of computers and advances in cryptography went hand in hand. Charles Babbage, whose idea for the Difference Engine presaged modern computers, was also interested in cryptography. During World War II, the Germans used the electromechanical Enigma machine to encrypt messages—and, famously, Alan Turing led a team in Britain that developed a similar machine to break the code, in the process laying some of the groundwork for the first modern computers. Cryptography got radically more complex as computers became available, but it remained the province of spies and generals for several more decades.