CipherUtil - Miscellaneous utilities.


package require CipherUtil


CipherUtil::wordToOrder word ?keepDups?
Generate a numeric string that indicates the alphabetic order of the letters in word. Example: "dog" -> 132. If there are more than 9 letters in the word then the ordering is indeterminate; values over 9 are reduced to a single digit. If the value of keepDups is 1, then all matching letters will be given the same value. Otherwise they will be given values that increase from their position in the word, going from left to right. For example, "that" -> 3214 if keepDups is 0, but "that" -> 3213 if keepDups is 1. keepDups defaults to 0.

CipherUtil::generateKeysquares word ?width? ?height?
Generate keysquares from a keyword using all known routes. A width of 5 is used unless otherwise indicated. If width and height are both 5 then this procedure will replace any occurrences of j with i.

CipherUtil::saveCipherToFile cipherObj chanid
Save a cipher to an open channel so that it can be loaded later using CipherUtil::readSavedCipher. If stdout is used as the channel id then the cipher will be printed to standard output.

CipherUtil::readCiphertext filename
Read a block of ciphertext from a file. If filename is - then the ciphertext will be read from standard input. Newlines in the ciphertext file will be replaced with a single space character. This procedure returns the ciphertext that was read from the file.

CipherUtil::readSavedCipher filename
Read in a cipher that was previously saved by CipherUtil::saveCipherToFile. This procedure returns a list of key-value pairs suitable for use as an argument to the Tcl command array set. This procedure does not create a new cipher object, rather, it returns enough information that the caller can use to create a new cipher object.

This has been deprecated by the caesar cipher type.

CipherUtil::loadK3Fragments filename
Load a saved aristocrat/patristocrat cipher from a file and construct a list of K3 alphabet fragments from the cipher's key.

CipherUtil::lreverse list
Reverse the elements in a Tcl list. I can't believe that the Tcl folks haven't included something like this in the core Tcl distribution. A new copy of the list is returned with the elements reversed.

CipherUtil::phillipsIoc ciphertext
Calculate the index of coincidence for each of the 6 unique keysquares of phillips cipher. This procedure returns a list of 7 values: The first is the average of the last 6.

CipherUtil::periodicIoc ciphertext
Calculate the index of coincidence for all columns in a periodic cipher. This procedure returns n+1 values, where the first is the average of all of the rest.

Back to the Index
Created on Wed Mar 31 08:18:25 PST 2004 Logo