Main content
Computer science theory
Course: Computer science theory > Unit 2
Lesson 1: Ancient cryptography- What is cryptography?
- The Caesar cipher
- Caesar Cipher Exploration
- Frequency Fingerprint Exploration
- Polyalphabetic cipher
- Polyalphabetic Exploration
- The one-time pad
- Perfect Secrecy Exploration
- Frequency stability property short film
- How uniform are you?
- The Enigma encryption machine
- Perfect secrecy
- Pseudorandom number generators
- Random Walk Exploration
© 2023 Khan AcademyTerms of usePrivacy PolicyCookie Notice
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?
- Isn't this used when paying over the internet?(62 votes)
- Yes, safe internet purchases involve encryption. When you buy something through an insecure network, though, encryption might not be used, therefore making it possible for someone to take your information.(44 votes)
- 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)
- 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)
- InBrit talks about wars that were started and fueled by encryption. What wars might these be? 1:12(18 votes)
- From the author:Wars were were often decided by encryption, for example watch the video on WW2 encryption machines. There were not 'started' by encryption...encryption is just another important weapon.(55 votes)
- 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)
- Yes, hackers use encryption (sometimes simple XOR encryption) to encrypt shell code. When the shell code is in need by malware, it is decrypted by an internal function and executed on machine. This makes it very tough for anti-viruses to detect malware without executing them.(1 vote)
- 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)
- 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)
- Can't people make their own languages to communicate secretly. It is very much possible. Cryptography wont help there.(5 votes)
- 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)
- Where is sal khan i miss him😭(6 votes)
- 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)
- 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(3 votes)
- So why do you need to know prime numbers and dice rolls to understand cryptography?(2 votes)
- Only for advanced modern cryptography that involves algorithms, key sharing, and computer programs. All you need to know for ancient cryptography is a basic sense of letters and numbers.(3 votes)
- What is the most common cipher?(2 votes)
- Probably DES (Data Encryption Standard). Also, try avoiding questions that can be Googled. You will get an answer alot faster that way. I was able to find several sites that agreed on that answer in thirty seconds.
The reason this is the most common cipher is because this is used for things like webpage encryption, and maybe even to keep your Khan Academy password.(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.