Cryptology Programs

Computer programs can aid the cryptographer in generating cipher documents as well as helping the cryptanalyst in testing algorithms for 'cracking' the codes. This page is a collection of my own short utilities written to experiment with classical cryptology as well as a gathering of links to other authors' programs.

Most of the cipher utilities are written assuming an alphabet of 26 latin-based uppercased characters but they can easily be adapted to extended (eg. accents, numerals and/or punctuation) or non-latin alphabets. The string ALPHA in each program contains the current alphabet. Use the 'comments' link at the bottom of this page to contact me about quirks to be addressed, features wanted and programs showing other techniques. A request from a reader for a way to encipher/decipher images has led to a simple byte-oriented substitution program.

Note: The programs are written in Java using the Unix philosophy of command line switches for option selection, system streams for redirection and modular construction for ease of modification. Program sources, batch files and test documents are delivered in zip format. Unzip the folder to your project directory/folder, compile with Java's JDK and have some fun. Those interested in learning how to program using Java may want to look at my Java tutorial site.


prep scans a file, removing characters not in the defined alphabet (displaying a summary) and formatting in character groups. Command line switches include: /f (figures written as words), /p (punctuation written as words (stop, query, etc.), /r random null characters, /u (uppercase letters) and /# character groups. The /a option aborts preparation as soon as a non-valid character occurs. prep defaults to five letter groups, X as null and removing figures and punctuation.


atbash enciphers plaintext by inverting the alphabet. 'A' becomes 'Z', 'B' becomes 'Y', etc. Options include choosing fold points so that the alphabet can be split prior to inversion. Decipher by using /d on the command line or by running the ciphertext through atbash a second time.


caesar enciphers plaintext by shifting the start point of the alphabet. For example 'A' becomes 'D', 'B' becomes 'E', etc. Command line options include /# to set the displacement (shift). Decipher by using /d on the command line or by running the ciphertext through caesar with a negative displacement of the same amount.


keyword enciphers plaintext using a key phrase known to the sender and receiver. The replacement phrase is the key phrase with duplicate characters removed and extended by the remaining alphabet characters. The command line option is the keyword or phrase to be used. The command line switch /<integer> adds a shift on the replacement phrase to hide short keyphrase issues. Decipher by using /d on the command line.


mapper is a generic monoalphabet translation program that can be used to encrypt or decrypt text. It is based on a twenty six character long string that is used as the map. This string can be created manually or by the mapset utility. A simple batch file is:

java mapper defghijklmnopqrstuvwxyzabc /caesar_shift=3 <plain.txt >cipher.txt

mapset will create an appropriate batch file for mapper to use. Its syntax is also very simple such as:

java mapset /atbash >mapAtbash.bat
java mapset /caesar /3 >mapCaesar.bat
java mapset /keyword /5 twas the night before christmas >mapKeyword.bat
java mapset /testmap >mapTest.bat

mapper can also be used as a cryptanalysis tool. For example, if a frequency analysis had identified 'A' as the most common letter and you want to test for 'A' remapped back to 'E', you could start with a batch like:

java mapper e????????????????????????? <code.txt >rpt.txt

which is easily built from the mapset /testmap example above.


Vigenère is a generic polyalphabet translation program that uses a keyword to select the alphabet used in generating the cipher character. The set of alphabets are simple displacements from the original alphabet. The command line option is the keyword or phrase to be used. Decipher by using /d on the command line.


StreamIt is an example of a synchronous streaming cipher which merges characters/bytes in plaintext with an encoding password or pseudorandon source using either modular addition or the XOR operator.

Character merging first tests for valid characters, then converts both streams to integer representation. After mudulo 26 addition, the result is converted back to a character for output. Merging bytes rather than characters allowings digitalized images and audio to be enciphered.

StreamIt accepts plaintext from the standard io stream. Use /C for character based encryption (byte form is default). Running the program a second time will reverse the encryption.

Frequency Counting

freq scans a file and issues a report of letter counts including digraphs and trigraphs. If the input file is plaintext, cryptologist may find that it is too 'regular' and tuning is needed before transmission. If the file is ciphertext, the report could be used in a first principles trial for solution.

Word Counting

wcPlus scans a file and prepares a report of word counts. If the input file is plaintext, careful use of the report would eliminate some patterns that make a text easy to analyze. For example, it would spot overuse of 'the' and 'of'. If the file is ciphertext, the report can be used in a first principles trial for solution.


Noise is random changes to letters or strings of letters. It can be deliberately introduced at the source or accidentally when messages are prepared, transmitted, received or transcribed. introduces this randomness into messages to challenge analysis using letter/word counts. pending

Links To Programs By Other Authors

Many students of cryptology have designed software for encryption and decryption of various codes. These are some that I have found on the internet:

Java Utilities

Ganzúa or PickLock by Adolfo Garcia is a multipurpose cryptanalysis tool.

jkrypto is a generator or analyzer and includes Kasiski testing.

JavaScript Utilities

Codebreaker has many JavaScript utilities for you to enjoy.

Affine Substitution Cipher (setting a=1 and b=3 yields Caesar Code).

Playfair Cipher Demonstrator lets you choose a keyword for generating the matrix.

Base64 is a standard method of enciphering bytes into ASCII text, developed for sending pictures and executables via e-mail. It can be used to hide messages from the naive but is not secure as deciphering utilities abound.

JR's Home Page | Comments | [cyprogs.htm:2014 02 04]