COMPUTER PROBLEMS: DAY 7

advertisement
COMPUTER PROBLEMS:
DAY 7
(1) Write programs to find the determinants of 2 × 2 and 3 × 3 matrices.
(2) You can use T Davis’ code as a text to number translation scheme. This code
can be found under Text to Number Code on my course 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. You may want to modify this code so that ’a’ converts
to 11. Practice this by encoding and decoding longer text messages.
(3) 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.
1
Download