railfence - Create and manipulate a railfence cipher


set cipherProc [cipher create railfence]

cipherProc configure ?options?
cipherProc cget option
cipherProc restore ct pt
cipherProc move rail direction
cipherProc swap rail1 rail2
cipherProc undo
cipherProc solve


cipherProc configure ?options?
Configure the settings for the railfence cipher. Valid options are:

cipherProc configure -ciphertext string
cipherProc configure -ct string
Set the ciphertext for this cipher instance to string. Invalid letters or numbers in the ciphertext are silently discarded.

cipherProc configure -period n
The number of rails for the cipher. This value is converted to a myszcowski-based period by using period * 2 - 2. Be warned that the period (number of rails) that you set is not the same as the period that is returned with cget -period (myszcowski period).
cipherProc configure -language language
This option is currently ignored for all cipher types. Set the current cipher language to language. If the cipher has a solve method then digram frequencies for this language are used to determine the best fit. If the language is not specified or not known then english is used.

cipherProc cget option
Look up the value for a given option. Valid options are:

cipherProc cget -type
Returns the type of this cipher. In this case, railfence

cipherProc cget -ciphertext
cipherProc cget -ct
Return the ciphertext for this cipher.

cipherProc cget -plaintext
cipherProc cget -pt
Return the plaintext for this cipher based on the current key setting.

cipherProc cget -key
Returns the current key setting for this cipher. The result can be passed back to this cipher instance or another cipher with the cipherProc restore subcommand.

cipherProc cget -length
Returns the length of the ciphertext for this cipher. 0 is returned if the ciphertext has not been set.

cipherProc cget -period
Return the period for this cipher.

cipherProc cget -language
Returns the name of the language used for this cipher.

cipherProc restore key
The restore command restores the cipher's key to a previously stored state. The output from cipherProc cget -key can be passed back into the restore command to implement a crude save feature. Example:

set key [$firstCipher cget -key]
$secondCipher restore [lindex $key 0] [lindex $key 1]

cipherProc move rail direction
Set the starting rail to the specified rail. The top rail is rail 0. The direction parameter describes the direction of the next rail in the sequence. For example:

cipherProc move 3 up

Will set the starting rail to the third rail from the top. The ciphertext will them be written out in an upward direction:

Example needed
This operation clears any swap operations that have been performed.

cipherProc swap rail1 rail2
Swap the two specified rails. This is not really a valid railfence operation, but is used for redefence ciphers.

cipherProc undo
Clears all changes that have been made to the ciphertext.

cipherProc solve
Iterate through all combinations of possible starting rails and directions. The key that produces plaintext with the highest digram frequency count is used as the solution.

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