so the keystream must be at least as long as the message. If the keystream is longer than the message, the message may be padded with an additional repeated character, thus denying the attacker knowledge of the exact length of the message. To encrypt a message: Remove all punctuation and spaces, leaving only the 26 letters A–Z. Convert each letter to its natural numerical value, A = 1, B = 2, ..., Z = 26. Generate one keystream value for each letter in the message using the keystream algorithm below. Add each keystream value to the corresponding plaintext number, subtracting 26 if the resulting value is greater than 26. (In mathematics this is called modular arithmetic.) Convert the resulting numbers back to letters. This sequence of letters is the ciphertext. To decrypt a ciphertext: Convert each letter in the ciphertext to its natural numerical value. Generate one keystream value for each letter in the ciphertext. Subtract each keystream value from the corresponding ciphertext value, adding 26 if the resulting value is less than 1. Convert the resulting numbers back to letters. Keystream algorithm This algorithm generates keystream values by moving cards within the deck. The keystream algorithm is deterministic, so the keystream values depend only on the initial order of the deck. The deck is assumed to be a circular array, meaning that should a card ever need to advance below the bottom card in the deck, it will simply rotate back to the top (in other words, the first card follows the last card). We will take for example this starting deck: 1 4 7 10 13 16 19 22 25 28 3 6 9 12 15 18 21 24 27 2 5 8 11 14 17 20 23 26 Perform these steps to generate one character of the keystream. Locate the A joker (value 27) and move it down the deck by one place. If it is the last card, it becomes the second card. There is no way for it to become the first card. The deck now looks like this: 1 4 7 10 13 16 19 22 25 28 3 6 9 12 15 18 21 24 2 27 5 8 11 14 17 20 23 26 Locate the B joker (value 28) and move it down the deck by two places. Notice that if it is the second to last card, it becomes the