1'8Modular arithmetic - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

1'8Modular arithmetic

Description:

In some situations we care only about the remainder of an integer when it is ... procedure for generating pseudorandom numbers is the linear congruential method. i.e. ... – PowerPoint PPT presentation

Number of Views:56
Avg rating:3.0/5.0
Slides: 13
Provided by: LO14
Category:

less

Transcript and Presenter's Notes

Title: 1'8Modular arithmetic


1
  • 1.8 Modular arithmetic
  • 1.8.1 Introduction
  • In some situations we care only about the
    remainder of an integer when it is divided by
    some specified integer.

2
  • 1.8.2 Definition
  • 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 r and 0 ? r lt m
  • Note that r is non-negative.

3
  • Example 1.8 - 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 wont work by writing
  • ?64 (?10) ? 6 (? 4)
  • because r (? 4) is not a non-negative number.

4
  • 1.8.3 Applications of modular integer arithmetic
    in computer science
  • 1.8.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.

5
  • Example 1.8 - 2
  • Assign a memory location to each of the following
    student numbers when m1024. Solve the following
    problem, allowing for collision.
  • Name Student number Memory Location
  • Peter 1234567 647
  • Michael 1352467 787
  • John 1347347 787
  • h(1234567) 1234567 mod 1024 647
  • h(1352467) 1352467 mod 1024 787
  • h(1347347) 1347347 mod 1024 787

6
  • 1.8.3.2 Pseudorandom 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.

7
  • Example 1.8 - 3
  • The sequence of pseudorandom numbers generated by
    choosing m9, a7, c4 and x03 can be found as
    follows
  • 7x04(7)(3)425 ? x1 25mod 97
  • 7x14(7)(7)453 ? x2 53mod 98
  • 7x24(7)(8)460 ? x3 60mod 96
  • 7x84(7)(5)4 39 ? x9 39 mod 93
  • 7x94(7)(3)4 25 ? x1025 mod 97

8
  • 1.8.3.2 Cryptology
  • - the study of secret messages

9
  • Generalised Caesars 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.

10
  • Example 18 - 4
  • Find the secret message to represent the message
    MEET YOU IN THE PARK using Caesar cipher with k
    3.
  • Step 1 k3
  • Step 2 12 - 4 - 4 - 19 24 - 14 - 20 8-13 19 -
    7 - 4 15 - 0 - 17 - 10
  • Step 3 15 - 7 - 7 - 22 1 - 17 - 23 11 - 16 22
    - 10 - 7 18 - 3 - 20 - 13
  • Step 4 PHHW - BRX - LQ - WKH - SDUN

11
  • 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.

12
  • Example 18 - 5
  • Find the original message of FXAT QJAM using
    Caesar cipher with k 9.
  • Step 1 k 9
  • Step 2 5 - 23 - 0 - 19 16 - 9 - 0 - 12
  • Step 3 22, 14, 17, 10 7, 0, 17, 3
  • Step 4 WORK HARD
Write a Comment
User Comments (0)
About PowerShow.com