Given ch, a character to encode, and k, the appropriate character in k. We encode as follows. (1) t1 = ch + k (2) t2 = t1 mod NUM_VALID_CHARACTERS (3) t3 = t2 + FIRST_VALID_CHARACTER How about decoding? We want to invert that. (4) t2 = t3 - FIRST_VALID_CHARACTER (5) t1 = t2 // Hard to undo mod (6) ch = t1 - k. Problem! What if this is outside the valid range? (I.e., because we used mod.) I *think* this means that we'll get a negative number, so we can just add it.