240 likes | 368 Views
Math for Liberal Studies – Fall 2008. Cryptography. Adding Security to Messages. How do we protect the security of the messages we send? This is a very important issue in the information age Consider the number of times you send information you hope is secure: text messaging e-mail
E N D
Math for Liberal Studies – Fall 2008 Cryptography
Adding Security to Messages • How do we protect the security of the messages we send? • This is a very important issue in the information age • Consider the number of times you send information you hope is secure: • text messaging • e-mail • online shopping • etc.
Prevention: Not an Option • It is largely impossible to prevent messages from being intercepted • Since we can’t keep people from reading our messages, we should try to disguise them so that the messages only make sense to the intended recipient • This process is called “encryption”
Encryption: Systems are Key • Whenever we encrypt a message, it is vital that we do it systematically • It is hard to keep messages secret, but much easier to have a secret system • Many systems are based on a keyword or phrase that is only known to a select few
Starting Simple: The Caesar Cipher • The simplest cipher was used originally by Julius Caesar • Take the letters of your message and change them according to this rule: • A D • B E • C F • D G • etc. • W Z • X A • Y B • Z C
An Example • ATTACK AT DAWN • This becomes DVVDFN DV GDZQ • Notice that the new message looks like nonsense, but we can recover the original message since we know the rule • Sometimes we will remove the spaces and write the message in blocks of equal numbers of letters: DVVD FNDV GDZQ • This further disguises our message
You Try It • The message XVHWK HIRUF HOXNH has been encoded using the Caesar cipher • Decode the message • USE THE FORCE LUKE
Generalizing Caesar • We can take the idea of the Caesar cipher and generalize it to make it more secure • Instead of always shifting 3 letters ahead in the alphabet, we can secretly agree on a number to shift
More Examples • Encode the message “RETREAT” using a Caesar cipher (shift 7) • YLAYLHA • The message “ACBU CCGS” was encoded using a Caesar cipher (shift 14). Decode the message • MONGOOSE
Problems • Even when we choose a secret number, this isn’t a very secure code • Whatever letter “A” gets encoded as, it will be encoded as the same letter throughout our message • Using “frequency analysis,” these types of codes are easy to break
Another Approach: Numbers • The new approach we will use is similar to the Caesar cipher • To make it easier, we will replace our letters with numbers: • A = 0 • B = 1 • C = 2 • etc. • Z = 25
Alphabet Math • Using these numbers, we can “add” two letters together • D + L = 3 + 11 = 14 = O • What about R + Y = 17 + 24 = 41? • When the total is over 41, we “wrap around” back to the beginning of the alphabet • Wrapping around means that we end up at 41 – 26 = 15 = P
Rethinking Caesar • Using this new idea, we can think of the original Caesar cipher as “Add D to every letter of the message” • If we choose a secret number to use for the Caesar cipher, we can think of that as choosing a secret letter • Why not choose a secret word?
Vignère Cipher • For this cipher, we choose a secret keyword • Write down your original message, and then write down the keyword beneath it, repeating as many times as needed • For example, suppose our keyword is MATH
An Example • THISISMYMESSAGE • MATHMATHMATHMAT • Now add the two rows together: • FHBZUSFFYELZMGX
Now You Try It • Encode the message HASTA LA VISTA BABY using the keyword ARNOLD • HRFH LOAM VGED BROM
Decoding • How do we decode a message using the Vignère cipher? • Instead of adding the keyword, we simply subtract • Reality check: Can we subtract F – R? • This would be 5 – 17 = -12, but we just wrap around again, so add 26 • -12 + 26 = 14 = O
An Example • Decode the message “REAFX PSLLM VILGF UIWV” using the keyword “JESSE” • I AIN’T GOT TIME TO BLEED
Another Level of Complexity • Even the Vignère cipher is relatively easy to crack, though it takes some more advanced techniques • Another cipher that uses some of the same ideas is called the Autokey cipher • Instead of repeating the keyword over and over, we only write it down once
Example • Suppose we want to encode the message “SAY HELLO TO MY LITTLE FRIEND” with keyword “PACINO” • This time we write down the original message, and on the next line, the keyword followed by the message again • SAYHELLOTOMYLITTLEFRIEND • PACINOSAYHELLOTOMYLITTLE • Now we add the two lines together as before: HAAPR ZDORV QJWWM HXCQZ BXYH
Your Turn • Encode the message “LORD OF THE RINGS” with the Autokey cipher using keyword “FRODO” • LORDOFTHERINGS • FRODOLORDOFTHE • QFFGCQHYHFNGNW
Decoding Autokey: Tricky • The problem with decoding a message using the Autokey cipher is that we don’t know what to subtract, since it includes the original message • We have to decode the message a little bit at a time
An Example • Decode the message “XHRVX HDSGG ATSAR TV” using the keyword “RETURN” • We know we need to subtract: XHRVXH DSGGAT SARTV RETURN FOREST MOONO FOREST MOONOF ENDOR
Extra Credit • Caesar cipher (shift 3) • RQWKH ILQDO HADPB RXZLO O • Vignère cipher (keyword: FINAL) • GMNSV JLSOC YPRSP HZRT • Autokey cipher (keyword: EXAM) • RRMNR LIIMT DPAPP VW