Cryptography Reference
In-Depth Information
FIGURE 5.6
EXERCISES
1.
Writing a program to encipher and decipher individual characters using affine trans-
formations is very easy. All you need do is use a method that computes inverses mod
n
, and the rest is as easy as writing the Caesar cipher. Write a TestAffineCipherApplet
class which tests the two static methods affineEncipher(), and affineDecipher(). These
last two methods should accept an array of bytes (a message), along with the enci-
phering key(s), and return an array of bytes. You must use primitive ints, so you need
to write a method to compute inverses modulo
n
for ints.
2.
Encipher, and then decipher, the following messages using Caesar shift transforma-
tions with the ordinary alphabet, and where the shift
b
= 23.
a.
KENNEDY IS DEAD
b.
HITLER IN PERU
c.
BIG BROTHER
3.
Repeat the previous exercise but use a single character affine cipher with a multiplier
of 15 and a shift of 6.
4.
Repeat the previous exercise, but use a block affine cipher with a block size of 4 char-
acters per block. Use 25252526, the appropriate value for the modulus (using the ordi-
nary alphabet), and use 1542327 for the multiplier, and 9923411 for the shift. Pad
messages that are not multiples of the block size with the letter X.
Search WWH ::




Custom Search