You can convert text to a list of numbers, or a list of numbers to text (using a goes to 0, b goes to 1 etc.) with the first two radio buttons. The result will be displayed in the output text area.
To apply the affine cipher e(x) = a*x + b to a list of integers, type in the list of integers (separated by commas or spaces), give a value for a and b, select the appropriate radio button (Apply a*x + b) and press the "Do the operation" button.
To apply the affine cipher e(x) = a*x + b to a String, clear the text field for integer input and enter text in the top text field. The remaining steps are the same as applying the cipher to a list of integers.
The list multiples operation will nicely print out the values 1*x, 2*x, 3*x, etc. up to 25*x, all reduced mod 26. This is used to calculate multiplicative inverses mod 26.
To use the Attack operation, enter text in the top text field, type in a value for a inverse (you must calculate this value, and each attack has a^-1 fixed), select the attack radio button and press the operation button.
To see the legal values for a or a^-1, press the Show a values button.
You can clear the output area at any time by pressing the Erase output button.
There is also an operation that calculates x mod 26, for an x value that you enter. Unfortunately, x must be an integer, not something like 21*17.
Here is an example to illustrate that you can actually use this applet to help perform a one-time pad encryption, followed by an example where we perform a known plaintext attack.
|
text
|
22 |
7
|
14
|
11
|
4
|
19
|
19
|
7
|
4
|
3
|
14
|
6
|
18
|
14
|
20
|
19
|
| key | 12 | 8 | 18 | 18 | 8 | 14 | 13 | 8 | 12 | 15 | 14 | 18 | 18 | 8 | 1 | 11 |
| sum | 6 | 15 | 6 | 3 | 12 | 7 | 6 | 15 | 16 | 18 | 2 | 24 | 10 | 22 | 21 | 4 |
The multiples, k*4 are:That indicates that a = 11 or a = 24. Substituting those values back into either of the equations 6a + b = 25 or 10a + b = 17, yield b = 11. Since a = 24 is not a valid value for an affine key, we see that a = 11 and b = 11. Let's check that both solutions would actually generate the given data. Type in 6, 10 to the integer text field, set a = 11 and b = 11 and run the encrypt operation to see that the results are 25 and 17 as stated. Now repeat with a = 24 and b = 11 to see that this also gives 25 and 17.
k = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
4*k= 4 8 12 16 20 24 2 6 10 14 18 22 0 4 8 12 16 20 24 2 6 10 14 18 22