GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Enigma(3) User Contributed Perl Documentation Enigma(3)

Crypt::Enigma - Perl implementation of the Enigma cipher

This module is a complete working Perl implementation of the Enigma Machine used during World War II. The cipher calculations are based on actual Enigma values and the resulting ciphered values are as would be expected from an Enigma Machine.

The implementation allows for all of the Rotors and Reflectors available to the real world Enigma to be used. A Steckerboard has also been implemented, allowing letter substitutions to be made.

The list of available rotors is as follows:

RotorI, RotorII, RotorIII, RotorIV, RotorV, RotorVI, RotorVII, RotorVIII, RotorBeta, RotorGamma.

The list of available reflectors is as follows:

ReflectorB, ReflectorBdunn, ReflectorC, ReflectorCdunn.

As with the real world Enigma, a minimum of 3 and a maximum of 5 rotors along with 1 reflector may be defined for each encryption/decryption.

  use Crypt::Enigma;

  my $args = {
    rotors       => [ 'RotorI', 'RotorII', 'RotorIII' ],
    startletters => [ 'A', 'B', 'C' ],
    ringsettings => [ '0', '5', '10' ],
    reflector    => 'ReflectorB',
  };

  $enigma = Crypt::Enigma->new( $args );

  # Change rotor settings
  $enigma->setRotor( 'RotorVI', 'Z', '3', 1 );

  # Set the letter substitutions
  $enigma->setSteckerBoard( [ 'G', 'C' ] );

  # Encode the plaintext
  $cipher_text = $enigma->cipher( $plain_text );

  # Decode the ciphertext 
  $plain_text = $enigma->cipher( $cipher_text );

A "Crypt::Enigma" object is created by calling the new constructor either with, or without arguments. If the constructor is called without arguments the defaults values will be used (unless these are set using the "setRotor" method detailed below).
new ( ARGS )
The arguments which can be used to create a "Crypt::Enigma" instance are as follows:

  -rotors
  -startletters
  -ringsettings
  -stecker
  -reflector
    

The first four are to be passed in as references to arrays, while the last argument is a scalar.

cipher ( ARGS )
This method crypts and decrypts the supplied argument containing a string of text. Any characters which are not from the English alphabet (punctuation, numerics, etc) are ignored.
setRotor ( ARGS )
The "setRotor" method is called to set a rotor of the Enigma to specific settings. The arguments to be passed in are as follows:

  -rotor name (eg. RotorI, RotorII, etc)
  -initial start letter (eg. 'A', 'B', etc)
  -ring setting (eg. '0', '1', etc)
  -rotor number (eg. '1', '2', etc)
    

If incorrect values are passed in, the default settings are used.

setReflector ( ARG )
The "setReflector" method is called to set the reflector of the Enigma Machine. The argument to be passed in is a string containing the name of any of the available reflectors.
setSteckerBoard ( ARGS )
The Steckerboard is set by calling the "setSteckerBoard" method and supplying a reference to an array as the first argument.

The array should contain a set of letter pairs, such as:

  [ 'A', 'B', 'C', 'D' ];
    

In this example, each instance of the letter 'A' will be replaced with the letter 'B' (and vice-versa) and each instance of the letter 'C' will be replaced with the letter 'D' (and vice-versa).

getRotorNames
Returns an array containing the rotor names currently defined for encryption/decryption.
getStartLetters
Returns an array containing the start letters currently defined for encryption/decryption.
getRingSettings
Returns an array containing the ring settings currently defined for encryption/decryption.
getReflector
Returns a string containing the name of the reflector currently defined for encryption/decryption.
dumpSettings
This method will print out (to STDERR) the current rotor settings.
setDebug ( ARG )
The "setDebug" method is used to set the debug value of the "Crypt::Enigma" object. The value of the argument can be either 1 (debug on) or 0 (debug off). The debug value is set to 0 by default.

None, but that does not mean there are not any.

Alistair Francis, <cpan@alizta.com>
2009-11-12 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.