← All articles
technologycryptographycipherssecuritySeptember 17, 20265 min read

What Is a Cipher? Rearranging Meaning So Only One Reader Can Recover It

By the BrainSnail editorial team. How these articles are written and checked, and how to tell us when one is wrong.

A code replaces whole words or ideas with agreed substitutes and needs a codebook. A cipher operates on individual letters or bits by a rule, and the rule is controlled by a key. That distinction sounds pedantic and turns out to be the whole subject, because a system whose security rests on nobody knowing the rule collapses the moment the rule leaks, while one whose security rests on the key can publish everything else.

The two basic operations

Almost every classical cipher is built from substitution, replacing each symbol with another, or transposition, keeping the symbols and rearranging their order, or both. The Caesar cipher shifts every letter a fixed number of places and has only twenty-five possible keys, so it can be broken by trying them all. A general substitution cipher, assigning each letter to an arbitrary different letter, has an enormous number of keys and is still broken easily, because it preserves letter frequencies: in English, e appears far more often than any other letter, and the pattern of common digraphs and short words gives the rest away. That technique, frequency analysis, was described by the ninth-century scholar al-Kindi in Baghdad and destroyed simple substitution for good. The response was polyalphabetic ciphers such as the Vigenere, which use several substitution alphabets in rotation according to a keyword, flattening the frequencies. These resisted analysis for centuries until methods were found to determine the key length, after which each position reduces to a simple Caesar cipher again.

Kerckhoffs's principle

The governing rule of the field was set out by Auguste Kerckhoffs in 1883: a cipher should remain secure even if everything about the system except the key is public knowledge. Claude Shannon restated it as the assumption that the enemy knows the system. The reasoning is practical rather than idealistic, since algorithms are used by many people over long periods and inevitably leak through defection, capture, reverse engineering or carelessness, while a key can be changed in a moment. It follows that secrecy of design, sometimes called security through obscurity, is not a defence, and modern cryptographic standards are published in full and attacked publicly for years before adoption precisely so that weaknesses are found by researchers rather than by adversaries. Systems that ignored this have failed repeatedly, including proprietary ciphers in mobile phones, transport cards and car immobilisers, all broken shortly after being reverse engineered.

The one unbreakable case

Exactly one cipher is provably secure and it is almost useless. The one-time pad combines the message with a key of random material that is at least as long as the message, used once and never again. Because every possible plaintext of that length corresponds to some key, an intercepted message gives an attacker no information whatever about which one was sent, a result Shannon proved formally in 1949. The conditions are unforgiving: the key must be truly random rather than generated by an algorithm, must be as long as everything ever sent, must be distributed securely in advance, and must never be reused. Reuse is catastrophic, as Soviet reuse of pad material allowed American and British analysts to read substantial traffic in the Venona project over decades. Since delivering a key as long as the message solves a problem no easier than delivering the message, the pad is confined to situations where couriers can move material in advance, and everything else uses ciphers that are merely computationally hard to break.

How modern ciphers are organised

Contemporary cryptography divides into two families that solve different problems and are used together:

  • Symmetric ciphers, where both parties share one secret key, which are fast and handle bulk data; the standard is the Advanced Encryption Standard, selected in 2001 after an open international competition, operating on blocks of 128 bits through repeated rounds of substitution and permutation
  • Stream ciphers, which generate a keystream combined with the data a bit at a time, suited to continuous traffic
  • Public key ciphers, where a published key encrypts and a private key decrypts, resting on problems believed hard such as factoring large numbers or discrete logarithms on elliptic curves, which solve the problem of agreeing a key with someone you have never met
  • Hash functions, which compress any input to a fixed-length fingerprint that cannot practically be reversed or duplicated, underpinning signatures and integrity checks
  • Modes of operation and authentication, which matter as much as the cipher, because encryption alone hides content without preventing tampering
  • In practice a connection uses public key methods to agree a session key, then a symmetric cipher for the traffic, which is exactly what happens when a browser opens a secure page

Where systems actually fail

Well-chosen modern ciphers are essentially never broken by direct mathematical attack on the algorithm. Real failures come from everything around them: keys generated with a weak random source, which has repeatedly produced predictable keys across whole product lines; keys stored where an attacker can read them; protocols that leak information through error messages or timing; implementations vulnerable to side channel attacks that measure power consumption, electromagnetic emissions or cache behaviour to extract a key from a device performing correct arithmetic; downgrade attacks forcing a connection back to obsolete algorithms; and people, who can be deceived, coerced or paid. The looming structural change is quantum computing, since a sufficiently large quantum computer would break the public key systems in current use, which has prompted a multi-year standardisation effort for post-quantum algorithms and a practical concern that encrypted traffic captured today could be stored and decrypted later.

The takeaway

A cipher transforms individual symbols according to a rule controlled by a key, unlike a code, which swaps whole words using a book. Classical ciphers substitute or rearrange, and simple substitution falls to frequency analysis. Kerckhoffs's principle holds that everything but the key should be publishable, which is why modern standards are open. The one-time pad is provably unbreakable and impractical. Real systems combine public key agreement with a symmetric cipher, and they fail through keys, implementations and people rather than mathematics.

Practise this

Questions from Cybersecurity

Reading about something is not the same as being able to recall it. These are real questions from the Cybersecurity unit in our Technology track, answers and explanations included. The unit has 114 in total across 22 steps.

  • Choose all that applyLevel 2

    1. Which of these can help prove who you are? (choose all that apply)

    • Passwordcorrect
    • Fingerprintcorrect
    • Face scancorrect
    • The screen color

    A password, a fingerprint, and a face scan can all prove your identity.

  • Sort into groupsLevel 5

    2. Sort each algorithm into Symmetric or Asymmetric encryption.

    Answer: AES = Symmetric; DES = Symmetric; RSA = Asymmetric; ECC = Asymmetric

    AES and DES use one shared key, while RSA and ECC use a public and private key pair.

  • Choose all that applyLevel 2

    3. Which of these are types of malware? (choose all that apply)

    • Viruscorrect
    • Wormcorrect
    • Trojancorrect
    • Keyboard

    Viruses, worms, and trojans are all kinds of harmful software.