Cryptography
Basics
05
Cryptography means secret writing. It is the art and science of sending secret messages and it has been used by generals and governments and everyday people practically since the invention of written language.
As we will see in this lesson, modern cryptographic techniques are essential to guaranteeing the security of our transactions on the Internet. Cryptography plays a role whenever you make an online purchase at Amazon or provide your password to Google. If we couldn't rely on those transactions being secure: i.e., being encrypted using some cryptographic algorithm, we really wouldn't have the Internet as we know it today.
This lesson focuses on some of the classical ciphers that followed the Caesar cipher, which Julius Caesar used in 34 B.C. Like the Caesar cipher, the other ciphers we will study in this lesson will be symmetric ciphers, which means that the same key is used both for encrypting and decrypting messages. As we will also see, all ciphers consist of two parts, the key and their algorithm. And it is the key, not the algorithm, that allows the cipher to create secret messages. In fact, in modern cryptography the algorithms are all based on open standards that are created by teams of experts, discussed openly and adopted and maintained by standards organizations.
So, let's take a look at some of the classical ciphers and some of the basic principles of cryptography. There are several hands-on activities in this lesson, where you'll have a chance to practice encrypting and decrypting messages and analyzing ciphers.
Technical Terminology
cipher - A cipher is a system for creating secret messages.
cryptography - Cryptography means, literally, 'secret writing'. The art and science of writing secret messages.
encryption - Encryption is the process of using a secret key to convert plaintext into ciphertext.
plaintext - Plaintext is the unencrypted, readable message.
ciphertext - Ciphertext is an unreadable, secret message.
decryption - Decryption is the process of using a secret key to convert ciphertext into plaintext.
encryption key - The encryption key is a piece of secret data used in by encryption and decryption algorithms.
encryption algorithm - The encryption algorithm uses a secret key to encrypt messages.
substitution cipher - In a substitution cipher letters from a ciphertext alphabet are substituted for the letters in a plaintext message in a systematic way.
transposition cipher - In a transposition cipher letters in the plaintext are rearranged without substitution
brute force attack - In cryptography, a brute force attack attempts to try every possible encryption key to break a secret message
frequency analysis - Frequency analysis counts the occurrence of the letters in an encrypted message in an effort to discover patterns that might reveal the encryption key
polyalphabetic substitution - In a polyalphabetic substitution system multiple alphabets are used to encrypt a single message
one time pad - The one time pad system is an example of perfect (unbreakable) encryption, which is achieved by using, only once, a random polyalphabetic key that is as long the message itself
key exchange problem - In cryptography, the key exchange problem is the problem of sharing a secret key between Alice and Bob, without Eve, an eavesdropper, being able to intercept it.
Introduction to Cryptography and the Caesar Cipher
Cryptography means secret writing. It is the art and science of sending secret messages and it has been used by generals and governments and everyday people practically since the invention of written language. Modern cryptographic techniques are essential to guaranteeing the security of our transactions on the Internet.
Cryptography plays a role whenever you make an online purchase at Amazon or provide your password to Google. Whenever you see the https protocol in your browser, you can rest assured that your communications are secure because they are being encrypted with strong, unbreakable encryption. If we couldn't rely on those transactions being secure we really wouldn't have the Internet as we know it today.
Next we will look at several different versions of cryptography, including the strong encryption that protects our Internet transactions. But let's begin here with a simple cipher, the Caesar cipher, so named because it was used by Julius Caesar in 34 B.C. The following video will explain the basics of the Caesar cipher.
Activity 1: Caesar Cipher
Use the Caesar cipher to encrypt your name by hand using the cipher_alphabet below that is shift 3. Then use the widget to check your answer.
PLAIN_ALPHABET: abcdefghijklmnopqrstuvwxyz
CIPHER_ALPHABET: DEFGHIJKLMNOPQRSTUVWXYZABC
Encrypt a short message for your partner by hand using the CIPHER_ALPHABET with shift 3 above. Trade the encrypted messages and decrypt them by hand. Use the widget to check your answer.
Create the CIPHER_ALPHABET that would result from a Caesar shift of 5. Use the widget on some letters with shift 5 to check your answer.
You may use this widget when working on the free response.
Activity 2: Simple Substitution Cipher
Use the Simple Substitution cipher to encrypt your name (message). Choose your own keyword to create a cipher alphabet. Then use the script to check your result.
For example if "tclark" is encrypted with the keyword "moron", the result is "TRHMQG", so if you try to decrypt "TRHMQG" using the keyword "moron" you should get back "tclark"
The following message word, SIRTQSMTCKJ, was encrypted with the keyword simple. Can you decrypt it?
Brute force attack. How many keys (arrangements of the alphabet) would you have to try to perform a brute force attack?
Activity 3: Frequency Analysis
One of the following messages below was encrypted using a substitution cipher and the other with a transposition cipher.
↓ Scroll down ↓ for two encrypted messages. Can you identify which is which? Paste the messages below into the frequency analyzer tool and observe their frequency histograms?
(lots of space for the output
Message 1:
nybfx ymjgj xytky nrjxn ybfxy mjbtw xytky nrjx nybfx ymjfl jtkbn xitrn ybfxy mjflj
tkktt qnxms jxxn ybfxy mjjut hmtkg jqnjk nybfx ymjju thmtk nshwj izqny dnyb fxymj
xjfxt stkqn lmyny bfxym jxjfx tstki fwpsj xxny bfxym jxuwn sltkm tujny bfxym jbnsy
jwtki jxufn wbjm fijaj wdymn slgjk twjzx bjmfi stymn slgjk twjzx bjbj wjfqq ltnsl inwjh
yytmj fajsb jbjwj fqqlt nslin wjhy ymjty mjwbf dnsxm twyym jujwn tibfx xtkfw qnpjy
mjuwj xjsy ujwnt iymfy xtrjt knyxs tnxnj xyfzy mtwny njxns xnxyj itsny xgjn slwjh jnaji
ktwlt titwk twjan qnsym jxzuj wqfyn ajijl wjjt khtru fwnxt stsqd
Message 2:
ttbti swhot istta osmwh gflhs tsecf liaho ondia henit ahena nwtpnf ewtie fpree rhbou
hnhbo uerli deovw rlode oeasr hrdsa itrei ttein ittie ntote gceoo rrits etegc psoya hsfmt
sesfm iahew dtseo oiewh pheet tecir uytss sohts ssoks isero oisen oeawa vtnee watne
ewagn rtenw egnit htwih tpiao reeet eoaoo sieuo tiiei ieidg dfvih pliee omrol setet wtese
iotao siaoo fwphe lwtof wtofs tsipt wtsid egfed gfweo gtaea grehn oeofl psrdm fssri
sdbnv foone avefi nweoi arowg fiaef nsteb isefc tieag ieare ahgha hrdhy irsoi rseli ceeli
ctryt ewskh nphst oahss nsrer oelur droan
Activity 4: Vigenere Cipher
Use the Vigenere cipher to encrypt your name. Choose your own keyword.
Decrypt the following message, which was encrypted using Vigenere cipher with the keyword zebras.
SLJJ IK OSMPADOLBSELHG
3. Frequency analysis: Use the Frequency Analyzer tool (above) to count the letter frequencies in the following text, which is the same text that was encrypted in an earlier exercise. In this case it was encrypted using Vigenere cipher. What differences do you observe from the histograms you used in the previous exercise?
sabjt zdffj tgexj dekhx xrslg ixfrk ssgki edwj kwsrx ivayd sgnik csnzt ozwuy esfip wfgnp
jjhfd wtzt ozwuy ewosd yoxai mzexh xxrsl gifgo ugsgz nuqie llasc jkws rxivs wzwpe
oxhki kilve tkhwr ibjof njbik fdwt ztozw uyeko vjegg elpge asabj tzdaj etwqs gueko ejiw
wgeev vwqcu yifff fwojd ytnez zhoft zhrhs exnvf lsod afies kphfi ffhji eusxp vandr xvwwq
ibcly nmoxd aqidk tzds uyejv ezznk gsskt zdtfi igcab jsgee scicd xivpj dwfet hdvj fdlge
ujoed sgztk msjji wrxbl tznvj kiwrm ojiks iefna swcv iffvf teaui ewojf spuoj essvv akmok
hwryq vrdzx jmevd ksve gegpd psqmt fngmp z
Still Curious?
Khan Academy video on What is Cryptography?
Khan Academy video on The Caesar cipher.
Video on Cryptography for the Internet.