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?

What is Cryptography? A story which takes us from Caesar to Claude Shannon. Created by Brit Cruise.

Want to join the conversation?

  • mr pink red style avatar for user Razeen Ahmed
    This seems really interesting but what grade do you learn this? (Im going into 7th.)
    (50 votes)
    Default Khan Academy avatar avatar for user
  • marcimus pink style avatar for user AT
    Isn't this used when paying over the internet?
    (62 votes)
    Default Khan Academy avatar avatar for user
  • 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)
    Default Khan Academy avatar avatar for user
    • 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)
  • 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?
    (18 votes)
    Default Khan Academy avatar avatar for user
  • 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 ?
    (22 votes)
    Default Khan Academy avatar avatar for user
  • leafers seedling style avatar for user Anisha B
    Woah! That is sooooo cool! But do we use cryptography in daily life? Are there some examples about it?
    (10 votes)
    Default Khan Academy avatar avatar for user
    • male robot hal style avatar for user Enn
      Yes, Cryptography is used a lot in daily life.
      The login at the start of Khan Academy and many other sites use cryptography to encrypt ones login details. E-commerce sites also depend heavily on cryptography to protect the credit card details of the those using its services.
      Some search engines encrypt searched keywords to ensure privacy.
      (8 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)
    Default Khan Academy avatar avatar for user
    • 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)
  • 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.
    (4 votes)
    Default Khan Academy avatar avatar for user
    • 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.
      (3 votes)
  • starky ultimate style avatar for user Derek Strider
    What would have it taken for Eve to descript the code?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • leaf green style avatar for user YangPeter
    You must learn about this!
    (4 votes)
    Default Khan Academy avatar avatar for user

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.