2008年12月15日 星期一

Maths(一)---Sets and Numbers(3)

hashing function

h(k ) = k modm

例一.

Assign a memory location to each of the following studentnumbers when m = 1024. Solve the problem if collisions occur.


h(1234567) = 1234567 mod 1024 = 647


h(1352467) = 1352467 mod 1024 = 787



h(1347347) = 1347347 mod 1024 = 787



Name Student number Memory Location

Peter 1234567 647
Michael 1 352467 787
John 1347347 788



Pseudorandom Number Generator






例一.

Cryptology
例一.
Find the secret message to represent the message “MEET YOUIN THE PARK” using Caesar cipher with k = 3.
Original message: MEET YOU IN THE PARK
p:        12-4-4-19 24-14-20 8-13 19-7-4 15-0-17-10
f (p):       15-7-7-22 1-17-23 11-16 22-10-7 18-3-20-13
Encrypted message: PHHW BRX LQ WKH SDUN
例二.
Find the original message of “FXAT QJAM” using Caesarcipher with k = 9.
Original message: FXAT QJAM
p:        5-23-0-19 16-9-0-12
f −1(p):      22-14-17-10 7-0-17-3
Decrypted message: WORK HARD

沒有留言: