COMPUTER PROBLEMS: DAY 4 mod 3035568337

advertisement
COMPUTER PROBLEMS:
DAY 4
(1) I encoded my credit card number via the algorith x → x97 mod 3035568337
(Hint: 3035568337 factors as 77929 ∗ 38953 ) The answer was 1047598204,
248322888 What is my credit card number (given in 2 blocks of 8 numbers)?
(2) Pick two (secret) random prime numbers p, q and an integer 0 < k < pq.
Encode a message via x → xk mod m where m = p ∗ q (and gcd(m, k) = 1!).
Share m, k with your neighbor and see if they can decode your message. (Don’t
forget to compute x → xk mod m via the repeated squaring method used last
time).
(3) You can use T Davis’ code as a text to number translation scheme. This code
can be found under Text to Number Code on the webpage. Once you’ve moved
the code into an appropriate file, type:
>>> from tdavis import *
To convert ’hello’ to strings of 4 numbers, type
>>> s2b(’hello’,2)
[4441, 4848, 5171]
Try s2b(’hello’,3) and s2b(’hello’,6). To convert [4441, 4848, 5171]
back, type
>>> b2s(_)
’hello@’
Note the padding ’@’. That is, since we are encoding with two characters
per block, the code adds an ’@’ symbol to our string so that it has an even
number of characters. Practice this by encoding and decoding longer text
messages.
(4) Using the text conversion code above, write a program that automates the
process of encoding and decoding text messages using RSA. You may also
want to design your program to automatically generate RSA keys.
(5) Write a program that checks if a number m is prime by picking 10 (or 100)
random numbers t and checking if tm−1 = 1 mod m. (Do this by repeated
squaring!)
1
Download