Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unit 2 Modular Arithmetic and Cryptography IT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLP 1 Unit 2 Modular Arithmetic and Cryptography.

Similar presentations


Presentation on theme: "Unit 2 Modular Arithmetic and Cryptography IT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLP 1 Unit 2 Modular Arithmetic and Cryptography."— Presentation transcript:

1 Unit 2 Modular Arithmetic and Cryptography IT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLP 1 Unit 2 Modular Arithmetic and Cryptography

2 Unit 02 Modular Arithmetic and Cryptography IT DisiciplineITD1111 Discrete Mathematics & Statistics STDTLP2 2. Modular Arithmetic and Cryptography 2.1 Introduction In some situations we care only about the remainder of an integer when it is divided by some specified integer.

3 Unit 02 Modular Arithmetic and Cryptography IT DisiciplineITD1111 Discrete Mathematics & Statistics STDTLP3 2.2Definition Let a be an integer and m be a positive integer. We use a mod m to denote the remainder when a is divided by m. It follows from the definition of remainder that a mod m is the integer r such that a = q m + rand0  r < m Note that r is non-negative.

4 Unit 02 Modular Arithmetic and Cryptography IT DisiciplineITD1111 Discrete Mathematics & Statistics STDTLP4 Example 2.2 - 1 32 mod 5 = 2 because 32 = 6  5 + 2 1997 mod 150 = 47 because 1997= 13  150 + 47 5 mod 8 = 5( 5 = 0  8 + 5)  64 mod 6 = 2(  64 = (  11 )  6 + 2) However, it won’t work by writing  64 = (  10)  6 + (  4) because r (=  4) is not a non-negative number.

5 Unit 02 Modular Arithmetic and Cryptography IT DisiciplineITD1111 Discrete Mathematics & Statistics STDTLP5 2.3 Applications of modular integer arithmetic in computer science 2.3.1 Using a hashing function to assign memory locations to computer files. One of the most common hashing functions is h(k) = k mod m where k is the key (reference) of a file and m is the number of available memory locations.

6 Unit 02 Modular Arithmetic and Cryptography IT DisiciplineITD1111 Discrete Mathematics & Statistics STDTLP6 Example 2.3.1-1 Assign a memory location to each of the following student numbers when m=1024. Solve the following problem, allowing for collision. Name Student number Memory Location Peter1234567647 Michael1352467787 John1347347787 h(1234567) = 1234567 mod 1024 = 647 h(1352467) = 1352467 mod 1024 = 787 h(1347347) = 1347347 mod 1024 = 787

7 Unit 02 Modular Arithmetic and Cryptography IT DisiciplineITD1111 Discrete Mathematics & Statistics STDTLP7 2.3.2Pseudorandom number generator -generates random numbers for needs such as computer simulations or random sampling in statistics -the most commonly used procedure for generating pseudorandom numbers is the linear congruential method. i.e.

8 Unit 02 Modular Arithmetic and Cryptography IT DisiciplineITD1111 Discrete Mathematics & Statistics STDTLP8 Example 2.3.2-1 The sequence of pseudorandom numbers generated by choosing m=9, a=7, c=4 and x 0 =3 can be found as follows: 7x 0 +4=(7)(3)+4=25  x 1 = 25mod 9=7 7x 1 +4=(7)(7)+4=53  x 2 = 53mod 9=8 7x 2 +4=(7)(8)+4=60  x 3 = 60mod 9=6  : 7x 8 +4=(7)(5)+4= 39  x 9 = 39 mod 9=3 7x 9 +4=(7)(3)+4= 25  x 10 =25 mod 9=7

9 Unit 02 Modular Arithmetic and Cryptography IT DisiciplineITD1111 Discrete Mathematics & Statistics STDTLP9 2.4Cryptology -the study of secret messages

10 Unit 02 Modular Arithmetic and Cryptography IT DisiciplineITD1111 Discrete Mathematics & Statistics STDTLP10 Generalised Caesar’s cipher process: 1.Choose a value of k where k is the number of letters to be shifted forward in the alphabet. 2.Replace each letter of the message by an integer p where 0  p  25 based on its position in the alphabet. 3.Replace each number p by the following shift cipher function f (p) = (p + k) mod 26 4.Translate the new number f (p) back to letter based on its position in the alphabet.

11 Unit 02 Modular Arithmetic and Cryptography IT DisiciplineITD1111 Discrete Mathematics & Statistics STDTLP11 Example 2.4 - 1 Find the secret message to represent the message “MEET YOU IN THE PARK” using Caesar cipher with k = 3. Step 1:k=3 Step 2: 12 - 4 - 4 - 19 24 - 14 - 20 8-1319 - 7 - 4 15 - 0 - 17 - 10 Step 3: 15 - 7 - 7 - 221 - 17 - 23 11 - 16 22 - 10 - 7 18 - 3 - 20 - 13 Step 4:PHHW - BRX - LQ - WKH - SDUN

12 Unit 02 Modular Arithmetic and Cryptography IT DisiciplineITD1111 Discrete Mathematics & Statistics STDTLP12 To recover the original message from a secret message encrypted by the Caesar cipher, the inverse function is used. The process of determining the original message from the encrypted message is called decryption.

13 Unit 02 Modular Arithmetic and Cryptography IT DisiciplineITD1111 Discrete Mathematics & Statistics STDTLP13 Example 2.4-2 Find the original message of “FXAT QJAM” using Caesar cipher with k = 9. Step 1:k = 9 Step 2:5 - 23 - 0 - 1916 - 9 - 0 - 12 Step 3:22, 14, 17, 107, 0, 17, 3 Step 4:WORKHARD


Download ppt "Unit 2 Modular Arithmetic and Cryptography IT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLP 1 Unit 2 Modular Arithmetic and Cryptography."

Similar presentations


Ads by Google