CISC 102 - Day 3

2024-09-11 17:50:14 -0400 EDT


Classical Cryptography

Julius Caesar was one of the first guys to do it. He assigned every letter to a number.

A B C D E F G H I J K L M
0 1 2 3 4 5 6 7 8 9 10 11 12
N O P Q R S T U V W X Y Z
14 15 16 17 18 19 20 21 22 23 24 25 26

What he would do is write a message, HELLO, convert each letter into they’re corresponding number, 7 4 11 11 15, then we would shift the letter number assignment by a few numbers.

A B C D E F G H I J K L M
4 5 6 7 8 9 10 11 12 13 14 15 16
N O P Q R S T U V W X Y Z
18 19 20 21 22 23 24 25 26 0 1 2 3

the example above is shifted 4 times over, or the key of this cipher is 4. Then caesar will convert the numbers through the shifted cipher, DAHHL.

This process is called the Caesar Cipher and can be expressed mathematically with:

$f(p) = (p + k) \mod (26)$, k = the key, p = the number corresponding to the letter

to decrypt a message you simply reverse the process of encryption which in this case can be expressed as:

$f^{-1}(p) = (p - k) \mod (26)$

You can take the Caesar Cipher even further by adding another key called $a, a \in \mathbb{N}$ to the equation in this configuration:

$f(p) = (ap + k) \mod (26)$

This is called an Affine Cipher. It should be noted that both the Affine cipher and Caesar cipher are private key cryptosystems, meaning they require both the sender and the recipient to already know the key(s) privately because once someone knows the key it can be very easily decrypted.

A public key cryptosystems is when some of the keys are publicly available. this may seem very insecure but is fine in actuality because the one key that is private is incredibly difficult to crack.

The most famous public key cipher is RSA. how it works is that calculate $n = (p-1) \times (q-1)$, where p and q are any prime numbers, and $e$ which is any number. $e$ and $n$ are the public keys.using $d$ and $e$, you find the private key $d, d \times e = 1 ( \mod 40)$. Then you encrypt your message with $d and $n$ with this formula:

$ C = M^e \mod n$, C = encrypted text, M = plain text

to decrypt the message, you use this formula:

$ M = C^d \mod n$,

This might seem to simple to crack because multiplying numbers is simple, but reversing prime factorization is extremely difficult, especially when the numbers are hundreds of digits long.