[an error occurred while processing this directive]

Improved 2-Letter Encoding Program

This program does the following:

  1. Prompts you to input a letter. Then outputs the letter (to your screen). This is done for 8 letters.
  2. Assigns a variable to your letter.  For example, the first letter is assigned to the variable letter1a.
  3. Assigns each variable a value of 1 through 26, depending on what letter it equals where A = 1, B = 2, .....Y = 25, Z = 26.  So if letter1a = "C", then letter1a = 3.  If you enter something other than a letter A-through-Z or you enter nothing at all and hit the return, the variable is assigned to the value " * "
  4. Subtract each letter variable value from 29 using the formulas letter1a = 29 - letter1a, letter2b = 29 -letter1b, letter3c = 29 - letter3c, etc..  So if letter1a=3, 3 is subtracted from 29 and letter1a becomes equal to 26.  Also, apply modular arithmetic in base 26 to this result so that any result over 26 will be assigned to the remainder after dividing by 26. For the case of * corresponding to a space, an undefined value is calculated, which is not a problem since it ultimately gives you "*".
  5. Assigns each new value back to a letter to produce a coded message.  So if letter1a is 5, letter1a is assigned the value becomes "E". Then outputs the letter. This is done for 8 letters. Note that if the letter variable was assigned a value of " *2 " or the new value is something other than a number from 1-to-26, it will output the value " * ". 
  6. Again, the code is programmed so any character with value ZERO is assigned to the letter "Z" in the final output.

How Can I Quickly Decode Messages Made With This Code?
You can use this same encoder to decode messages.  Here's Why. To reverse the operation of subtracting from 29, we simply subtract the result from 29 again. For example, if the original letter is "D", we get  29 - 4 = 25 which corresponds to "Y".  If we subtract 25, the number value of "Y" from 29, we get back 4 which indicates our original letter "D" again.

This Code Is Good, But Not Good Enough!
Unless one is looking specifically for the type of difference formula used in this code, they will not see any type of pattern. So to the casual observer, this is a very difficult code to break. But, if one has a computer program set up with many different deciphering algorithms, including one set up for various difference functions, they could crack this code in a matter of minutes. So to the person armed with some mathematical and computer skills, this code would be a piece of cake to crack.

Can We Use Different Formulas For Each Letter?
Yes, you can, provided that no two different letters are coded into the same letter. That task can be quite difficult and is another instance where a thorough knowledge of Abstract Algebra is essential. Such a code would be difficult to break.

Ready To Make Your Own Codes?
Go to this Student Coding Resource Page for instructions.


[an error occurred while processing this directive]