






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
This document offers a foundational introduction to cryptography, exploring its core principles and applications. it covers essential concepts such as encryption, decryption, modular arithmetic, prime numbers, and classical ciphers like substitution and transposition ciphers. well-structured and provides clear explanations, making it suitable for introductory-level learning in mathematics or computer science.
Typology: Study notes
1 / 11
This page cannot be seen from the preview
Don't miss anything!
Hey there, future cryptographers! ๐ This classwork is your mission briefing to the fascinating world of cryptography, where mathematics meets mystery. We'll explore how numbers, equations, and clever logic are used to create secret codes and secure information in our digital world. Get ready to dive into a world of ciphers, keys, and mind-bending concepts! What is Cryptography? Imagine you have a secret message for your friend, but you don't want anyone else to read it. Cryptography is the art and science of transforming your message into an unreadable format, called ciphertext , and then back again. It's like having a secret language that only you and your friend understand! The process of transforming the message into ciphertext is called encryption , and the reverse process, turning ciphertext back into the original message, is called decryption. Why is Cryptography Important? In today's digital age, cryptography is super important for: โ Secure communication: Protecting emails, texts, and online chats. โ Online banking and shopping: Keeping your transactions safe from hackers. โ Data security: Securing sensitive information like passwords, medical records, and government secrets. โ Digital signatures: Verifying the authenticity of documents and software. โ Network Security: Ensuring that data transmitted over computer networks is protected from eavesdropping and tampering. โ Software Security: Protecting software code from unauthorized modification and reverse engineering.
Before we dive into secret codes, let's review the math concepts that make it all possible.
Imagine a clock. When you add hours, you don't keep counting forever; you cycle back to 12 (or 24, depending on the clock). Modular arithmetic is similar, but with different "clocks." It's a system of arithmetic for integers, where numbers "wrap around" upon reaching a certain value, called the modulus. Definition: Let a, b, and m be integers. We say that "a is congruent to b modulo m" if m divides the difference (a - b). In other words, a and b have the same remainder when divided
by m. We write this as: a โกb (mod m) โ m is called the modulus. โ The remainder is always between 0 and m-1. Example 1: โ 17 โก2 (mod 5) because 5 divides (17 - 2 = 15). When you divide 17 by 5, you get a remainder of 2. Similarly, when you divide 2 by 5, you also get a remainder of 2. โ 25 โก1 (mod 8) because 8 divides (25 - 1 = 24). 25 divided by 8 is 3 with a remainder of 1. 1 divided by 8 is 0 with a remainder of 1. โ 12 โก0 (mod 3) because 3 divides (12 - 0 = 12). 12 divided by 3 is 4 with a remainder of
โ ((4 * 3) - 1) mod 7 = (12 - 1) mod 7 = 11 mod 7 = 4 โ (5^2) mod 7 = 25 mod 7 = 4 1.1.2 Modular Inverses In regular arithmetic, the inverse of a number 'a' is a number 'b' such that a * b = 1. For example, the inverse of 2 is 1/2, because 2 * (1/2) = 1. In modular arithmetic, we look for an integer 'b' that, when multiplied by 'a', leaves a remainder of 1 when divided by the modulus 'm'. The modular inverse of 'a' modulo 'm' is an integer 'b' such that: a * b โก1 (mod m) The modular inverse exists if and only if a and m are relatively prime (i.e., their greatest common divisor is 1). This is a crucial condition. Example 3: Find the modular inverse of 3 modulo 7. We need to find a number 'b' such that 3 * b โก1 (mod 7). By trying out numbers (or using the
square root of N, if they haven't been crossed out, must be prime.
The greatest common divisor (GCD) of two integers 'a' and 'b' is the largest positive integer that divides both 'a' and 'b' without leaving a remainder. It's also known as the highest common factor (HCF). Example 5: Find the GCD of 24 and 36. The divisors of 24 are: 1, 2, 3, 4, 6, 8, 12, and 24. The divisors of 36 are: 1, 2, 3, 4, 6, 9, 12, 18, and 36. The common divisors are: 1, 2, 3, 4, 6, and 12. The greatest common divisor is 12. Example 6: Find the GCD of 15 and 25. The divisors of 15 are 1, 3, 5, and 15. The divisors of 25 are 1, 5, and 25. The greatest common divisor is 5. 1.3.1 Euclidean Algorithm The Euclidean algorithm is an efficient method for finding the GCD of two integers. It avoids the need to list all the divisors. Steps:
Substitution ciphers replace letters in the plaintext with other letters, numbers, or symbols to create the ciphertext. They are among the earliest and simplest forms of encryption. 2.1.1 Caesar Cipher The Caesar cipher is one of the simplest and earliest known encryption techniques. It involves shifting each letter in the plaintext by a fixed number of positions down the alphabet. The shift value is the "key." Julius Caesar used this cipher to communicate with his generals. Example 7: Encrypt the message "HELLO" using a Caesar cipher with a key of 3. Plaintext: HELLO Shift each letter by 3 positions: โ H becomes K โ E becomes H โ L becomes O โ L becomes O โ O becomes R Ciphertext: KHOOR Decryption: To decrypt, shift each letter in the ciphertext back by the same key value.
Encrypt "SECRET": โ S becomes L โ E becomes E โ C becomes C โ R becomes R โ E becomes E โ T becomes T Ciphertext: LECRET Example 9: Plaintext Alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ Ciphertext Alphabet: ZEBRASCDFGHIJKLMNOPQTUVWXY Encrypt the message "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG" T becomes H H becomes I E becomes D becomes Q becomes O U becomes P I becomes A C becomes B K becomes C becomes B becomes R R becomes O O becomes N W becomes W N becomes S becomes F becomes J O becomes U X becomes M becomes J becomes K U becomes U M becomes P S becomes S becomes O becomes U V becomes V E becomes E R becomes R
becomes T becomes H H becomes I E becomes D becomes L becomes N A becomes Z Z becomes A Y becomes Y becomes D becomes X O becomes O G becomes G Ciphertext: HID OPA BCROWS JUMOS UVIR HID SNAY XOG
Transposition ciphers do not replace letters but rearrange them to create the ciphertext. The letters of the plaintext are scrambled according to some rule. 2.2.1 Rail Fence Cipher The rail fence cipher writes the plaintext in a zigzag pattern on imaginary "rails" and then reads the ciphertext row by row. Example 9: Encrypt the message "ATTACK AT DAWN" using a rail fence cipher with 2 rails. Plaintext: ATTACK AT DAWN Rails: A T A K A D A N T C T W Ciphertext: ATAKADANTCTW Example 10: Encrypt the message ""SEND HELP IMMEDIATELY"" using a rail fence cipher with 3 rails. Plaintext: SEND HELP IMMEDIATELY Rails: S N H L M E I T E D E P E A E L H I D Y Ciphertext: SNHLMEITED EPEAEL HIDY 2.2.2 Columnar Transposition Cipher In the columnar transposition cipher, the plaintext is written in rows of a fixed length, and then the columns are read out in a specific order. The order of the columns becomes the key for decryption.
integers less than n that are relatively prime to n.
โ Deterministic: The same input always produces the same output. โ Quick to compute: It should be easy to calculate the hash of any input. โ Preimage resistant: It should be computationally infeasible to find the input given its hash. โ Second preimage resistant: It should be computationally infeasible to find a different input with the same hash as a given input. โ Collision resistant: It should be computationally infeasible to find two different inputs that produce the same hash. Applications of hash functions: โ Password storage: Hashing passwords instead of storing them in plaintext. โ Data integrity: Verifying that a file has not been tampered with. โ Digital signatures: Creating a unique fingerprint of a document. โ Cryptocurrency: Ensuring the integrity of blockchain transactions. Example 11: SHA- SHA-256 (Secure Hash Algorithm 256) is a widely used cryptographic hash function that produces a 256-bit hash value. import hashlib message = "Hello, world!" hash_object = hashlib.sha256(message.encode()) hash_hex = hash_object.hexdigest() print(hash_hex) # Output: b7f7e09c4d17b1f54017d2685511121905753599a9c68e16359f4c12ef2a4d Conclusion Congratulations, you've completed your cryptography 101 mission! ๐ You've learned the basic math behind cryptography, explored classical ciphers, and discovered the magic of modern encryption techniques. Cryptography is a constantly evolving field, with new challenges and discoveries every day. So, keep exploring, keep questioning, and keep cracking those codes! Further Exploration โ Books: โ "The Code Book" by Simon Singh โ "An Introduction to Mathematical Cryptography" by Jeffrey Hoffstein, Jill Pipher, and Joseph H. Silverman โ Online Resources: โ Khan Academy: Cryptography โ Coursera: Cryptography courses โ YouTube: Cryptography tutorials