Cryptography and Secret Codes or one reason that linear equations are cool. Basic Cryptography Code A B C D E F G H I J K L MN O P Q R S T U VWX Y Z D E F G H I J K L MN O P Q R S T U VWX Y Z A B C • Romans would use this type of code • Here “LINEAR” becomes “OLQHDU” • What would “HTXDWLRQ” be? Numerical Code • We can do more if we change letters into numbers: A B C D E F G H I J K L MN O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 • So that “FWJH” becomes “6 23 10 8” • Can you come up with another example? Numerical Codes • Or we can even modify this code! A B C D E F G H I J K L MN O P Q R S T U VW X Y Z 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 • Here “FWJH” becomes “9 26 13 11” • Writing code like a table is hard though. • Can you think of a simple rule to describe this code? Linear Codes • The rule we came up with “Change it to a number and add 3” is a linear code • It is more easily written with the linear equation y=x+3 • To encode “MUSTANGS” first change each letter to a number, and then apply the linear equation • M 13 16; U 21 24; etc. Linear codes • How would you write “MUSTANG ON” in the linear code y=2x+5? • First turn it into numbers: “13 21 19 20 1 14 7 21 14” • Then apply the linear code: “31 47 43 45 7 33 19 47 33” • Now try with the linear code y=-3x+80 • How might we undo this? A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Linear Block Codes • Linear block codes use more than one equation to make a code. How might you do this? • First take a message “CRYPTOGRAPHY” and break it up into blocks. • Here we will use block size 2, so CR-YP-TO-GRAP-HY are the blocks. Linear Block Codes • You then need as many linear equations as your block size. • We need 2 equations, so let’s use y=2x+5 and y=-3x+80 • To make a code for CRYPTOGRAPHY, first take the first block ‘CR’ and encode it. • C 3 2*3+5=11; R 18 -3*18+80=26 • So ‘CR’ becomes ‘11 26’. What is the rest of the code? A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 A Problem • Now encode “BOOT” using this block system. • It becomes ‘9 35 35 20’ • The problem is that ‘O’ is encoded as ‘35’ for both rules. This is called collision. • You can tell there is a double letter. • To see this, solve the equation 2x+5=-3x+80 for x. A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Review • Codes: Assign a new symbol to each letter • Numerical Codes: Use numbers as the symbol • Linear Codes: Use linear equations to change the numbers • Linear Block Codes: Use more than one linear equation at a time • Collision: When the same letter is changed to the same number in a linear block code Now go make your own code!