Alphabetic Code Key Creation
An Alternative to the Traditional Way to Create Mono-Alphabetic Substitution Keys.
©2013, Bob Beeman
Updated 2013-07-27 @ 17:59 EDT (UT-4)
Read More
Important Notice

Do not use anything on this page for information that actually needs to be secure.

Those using monoalphabetic substitution codes (seriously obsolete and insecure for at least the past 250 years) have been told in countless books, and by the American Cryptogram Association that the way to create a substitution key is to follow this procedure:

  1. Start with a seed: "I am Captain Kirk".
  2. Sanitize Seed.
    1. Remove spaces and non-alphabetic characters and convert to all UPPER CASE.
    2. Eliminate repeated letters.
  3. Generate Key.
    1. Fill in cyphertext letters sequentially beginning with A, then B, etc.
    2. Fill in the remaining cyphertext letters in alphabetical order.
This is automated below. Try your own seed and see what results:
Plaintext a b c d e f g h i j k l m n o p q r s t u v w x y z  

The shortcomings of this method are obvious. Plaintext letters early in the alphabet tend to be represented by common letters, and plaintext letters near the end of the alphabet tend to be represented by less common leters, often themselves (U - Z in this illustration). Not a pretty picture!

So here's an alternative.

  1. Start with a seed "I am Captain Kirk".
  2. Remove spaces and non-alphabetic characters and convert to all UPPER CASE.
  3. The seed letters represent "jumps" per their alphabetic value:
    A = 1, B = 2, C = 3, D = 4, E = 5, F = 6, G = 7, H = 8, I = 9, ... , V = 22, W = 23, X = 24, Y = 25, Z = 26.
  4. In our example, the first seed letter is "I", which has the value 9.
  5. From the first letter of the alphabet, (A) go forward 9 letters to "J".
  6. "a" is now represented by "J".
  7. There are now only 25 plaintext letters left to be represented: b - z, and only 25 ciphertext letters left to represent them A - I and K - Z.
  8. The second seed letter is "A", which means move forward one letter from "J" to "K".
  9. "b" is now represented by "K".
  10. Continue this procedure, repeating the use of the seed as needed until the entire alphabet is covered. At each step one plaintext letter will be eliminated as will one CIPHERTEXT letter. Eventually all 26 letters will be eliminated. The 26 letters of seed that will be used are: "IAMCAPTAINKIRKIAMCAPTAINKI".
  11. The last (26th) letter of the seed doesn't actually do anything, because by the time it is used only one plaintext and one ciphertext character remain, and they will inevitably be paired regardless of the identity of the last seed character.
  12. The "Recycle Key" button takes the characters of the Ciphertext and inputs them, in reverse order, into the seed input, which can then be used to create a new Key.
  13. There is at least one "weak key" pair when keys are recycled:
    The second of the two results from recycling the first and remains the same when it is recycled itself.
This is automated below. Try your own seed and see what results:
Plaintext a b c d e f g h i j k l m n o p q r s t u v w x y z

Plaintext a b c d e f g h i j k l m n o p q r s t u v w x y z

Sometimes it is necessary or desirable to create a seed from a much longer string of text, commonly called a "Passphrase". The reason why this is a good idea is that people are very bad at thinking up random sequences. A long phrase or sentence, however, gives a lot of possibilities. The question is how to turn a passphrase into a seed, as per the previous section. Creating a small string of characters that contains much of the "randomness" of a long phrase is called "hashing". Proper hashing requires that at least the following conditions be met:

  1. The hash has a standard length output that does not depend on the length of the input, or at least this is true given that the passphrase has at least some small minimum length.
  2. Changing, adding, or subtracting one character of the input (passphrase) to the hash will cause a large and unpredictable change in most of the output characters.
  3. There is no known method to reverse the hash to recover the passphrase.

Read More
The code 4A5L is so named because it encodes a block of 4 US-ASCII characters from the subset shown below, into 5 UPPER CASE US-ASCII letters. Essentially, it does a base-conversion operation between base 58 (ASCII) and base 26 (Letters). Push the "Decode" Button to demonstrate decoding of 5-letter blocks to the less restrictive character set defined below. "[sp]" signifies the ASCII "space" (decimal 32, Hex 20) character, and "[cr]" signifies the ASCII "newLine" character appropriate to your operating system.


The restricted subset of ascii input characters is defined in the variable chars4A5L and presently consist of the characters shown above. These are all of the 54 defined morse code letters, numbers, punctuation in the table near the bottom of the Wikipedia Morse Code article plus the characters {space}, "%", "*", and {CR}. These were added to explicitly encode "* and "%", spaces between words, and carriage returns, allowing paragraphs to be separated. The software on this page converts everything to lower case and eliminates characters that can't be encoded before encoding the items in the top box and placing the encoded text in the bottom box. The button associated with each box fills the other box with the encoded/decoded information.

There are only 11,316,496 numbers (0 - 11,316,495) represented by 4 characters in base 58 whereas there are 11,881,376 numbers represented by 5 characters in base 26. For this reason there are 564,880 numbers (from 11,316,496 through 11,881,375) in base 26 that don't represent anything in base 58. These base26 that have no base58 equivalent run from "YTWJW" to "ZZZZZ". If this is the input to a code, having a gap in the cyphertext this large is not a good thing, as it can serve as a kind of "frequency table" crib.

If this code is used as the input to a cypher, this could be eliminated as a problem if during encoding of each block a (pseudo) random number between 0 and 11,881,375 is generated. If this number is larger than 10,751,615, then a block of 5 UPPER CASE characters is inserted into the ciphertext with an encoded value equal to the random number. These would be inserted upon encoding and ignored on decoding.

This page is copyrighted "freeware"
©2013, Bob Beeman
That means that although it is copyrighted, it is intended for you to use for your education or entertainment. Use for any other purpose is a violation of the copyright. You may use it yourself, copy and redistribute it, or even put it on your own website. I ask only that you not make any changes, and that you credit me as the source and reproduce this Notice unaltered and in its entirety. If you reuse any of the code, make sure to list me as one of your sources.

My only reward for writing this is the 15 milliseconds of fame I receive from having my name here. Don't deprive me of that.

You can copy this page by simply doing a "Save As" in your browser and putting it somewhere on your hard drive (or your web site). If you stop there the background will be gone. To preserve the background, copy the following file into this same folder, without changing its name, by again using your browser's "Save As". The next time you refresh the page, the background should be restored:


I make NO guarantee of any kind.
This page may contain serious errors.
Use this page entirely at your own risk!
This page is for entertainment purposes only.

I am not an accountant, doctor, financial advisor, or lawyer.
Nothing on this page or anywhere on this site should be construed as
financial, investing, legal, or medical advice.