If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

What is cryptography?

Cryptography has a rich history and plays a crucial role in modern communication networks. Learn about data encryption techniques through an example where Alice and Bob use secret codes (ciphers) to communicate privately. We'll learn about how encryption (locking messages) and decryption (unlocking messages) protect information from eavesdroppers like Eve. 

 

.
Created by Brit Cruise.

Want to join the conversation?

  • ohnoes default style avatar for user Kyle
    How exactly do people read peoples private messages (electronically, and non-electronically? And do they do it without letting the people sending and receiving messages know about it?
    (0 votes)
    • mr pants teal style avatar for user ExpiredPopsicle
      Sending information over the internet is equivalent to writing a message on a postcard and sending it through the mail in that anyone in the post office (or internet service provider) can snoop on your private messages just by looking at it.



      Software programs called packet sniffers can let a user see any information that reaches their network card on their computer, and older networking equipment (hubs and coaxial networks) would naively broadcast all that information to everyone connected to it, with the assumption that each computer would just screen out any information that wasn't meant for it.



      That hardware is less common now as more advanced (and faster) "switches" gradually replaced hubs. Switches are designed to only send the data to the intended computer. It is possible to fool a switch into sending the data to places it shouldn't go, but it requires that the eavesdropper actively tamper with the network, making it possible for them to be detected.
      (150 votes)
  • marcimus pink style avatar for user AT
    Isn't this used when paying over the internet?
    (63 votes)
  • orange juice squid orange style avatar for user osa
    In Brit talks about wars that were started and fueled by encryption. What wars might these be?
    (16 votes)
  • leaf blue style avatar for user Miguel Acero
    I am very interested in cryptography and i really hope this series takes off, a question though; couldn't cryptography be used unethically in malware/virus's ?
    (23 votes)
  • male robot hal style avatar for user JB
    Where does encoding come into play. Is this part of creating the "cypher?" Technically it is different from encrypting? Am I right I always confuse the two?
    (2 votes)
    • leafers sapling style avatar for user Peter Collingridge
      Encoding and encrypting are often used interchangeably. I would say that encrypting is used when you want to prevent some people from understanding a message, while encoding is when you want to transform the message but for it still to be read.

      For example a message in English might be encoded using Morse code so it could be transmitted more easily and efficiently. If you thought someone might be listening to the line, you could also encrypt the message, for example, by using a Caesar cypher.

      I suppose normally encoding would mean converting the form of the message, from text to binary numbers say. Whilst encrypting would not necessarily change the form, but convert from one set of letters to a different set. However, you can also create cyphers to convert text to numbers or something else that obscures the meaning.
      (21 votes)
  • blobby green style avatar for user THOMASD
    Where is sal khan i miss him😭
    (9 votes)
    Default Khan Academy avatar avatar for user
  • starky tree style avatar for user Abhishek Suresh
    Can't people make their own languages to communicate secretly. It is very much possible. Cryptography wont help there.
    (5 votes)
    • piceratops ultimate style avatar for user Piquan
      There are things like the Navajo Wind Talkers that do similar things. However, modern code-breaking and linguistic analysis techniques can help still. In similar ways, we sometimes find ancient books in languages we don't know, and slowly analyze them to understand what they are saying.

      For example, suppose that you can eavesdrop on a spy's communications, but don't know what the words mean. You get the local newspaper to put in a fake story that there will be no water the next week. Then, you see the spy write a message that includes the word "kai" several times, when he never used the word "kai" before. Now, you suspect that the word "kai" means "water". (The US did something similar in World War II, which helped the Allies turn the tide of the war; see https://en.wikipedia.org/wiki/Battle_of_Midway#Allied_code-breaking .)

      One common mistake among early cryptographer enthusiasts is to make a new "language" that's just an old language with the letters changed. My friends and I used to pass notes in invented ciphers like that, just as practice breaking codes!

      If you invent a language that's close to other human languages - such as if it has the same sentence structure as Sanskrit - then it becomes a lot easier to figure out how the language works.
      (4 votes)
  • blobby green style avatar for user maxkim0605
    I heard that there are some games that are known to be "NP-perfect" problems. What i want to ask is if it is possible to make a cipher using the board game Rush hour, by matching a random sentence to a distribution of cars in a certain size of the board.
    (4 votes)
    • male robot hal style avatar for user Cameron
      When converting any problem into a cipher, you need to think about, how three things are represented:
      -message text
      -key
      -cipher text

      I haven't played Rush Hour before, so this might not exactly work with the rules as I've written, but you'll probably get the idea of how to go about these kind of things.

      So, presumably we want to make the solution to the rush hour puzzle the key. If we know the solution, this should give us the key to convert the cipher text into message text. It's important that we only use solutions that are unique, to prevent ambiguous decoding i.e. we don't want to have more than one possible message.

      Presumably, we want the cipher text to involve the puzzle. So, we could possibly make the cipher text, the initial board set up, and then we say that a piece can only be moved 1 space per turn. Every turn we overlay a different grid of letters on the board.

      So, the message text is revealed by the spot a piece moved to (newly covered) that turn.

      So, would this be a strong cipher ?
      Probably not, for the following reasons:
      - The beginning and ending moves are probably easy to solve. This makes it susceptible to leaking info from the front and end of the message. Padding the message front and back could help prevent this.
      -Since it is a logic type problem, each move is dependent on the previous moves. This tends to make the difficult of each move add rather than multiply. It also makes a leak of 1 bit of the key reduce the strength of the key by more than 1 bit.

      Hope this makes sense
      (4 votes)
  • blobby green style avatar for user Antonio Garcia
    So why do you need to know prime numbers and dice rolls to understand cryptography?
    (2 votes)
  • ohnoes default style avatar for user malinda.gershony
    What is encryption and deycription again?
    (2 votes)

Video transcript

Imagine two people who share an important secret have to split up. This requires them to communicate private information from a distance. However, an eavesdropper named Eve also wants this information, and has the ability to intercept their messages. So, Alice decides to communicate using letters written in some kind of secret code. The following analogy is helpful. First, Alice locks her message in a box, using a lock that only she and Bob know the combination to. This is known as 'encryption.' Then, the locked message is sent to Bob. When Bob receives the box, he opens it using the code they shared in advance. This is called 'decryption.' Cryptography begins when we abandon physical locks and use 'ciphers' instead. Think of [ciphers] as virtual locks. Ciphers allow Alice and Bob to scramble and descramble their messages so that they would appear meaningless if Eve intercepted them. Cryptography has been around for thousands of years. It has decided wars, and is at the heart of the worldwide communication network today. The fascinating story of cryptography requires us to understand two very old ideas related to number theory and probability theory.