Mercurial > public > enigma
changeset 36:8347542c24a3
Added key_from_file to the user's guide.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 03 Jun 2012 18:35:22 -0500 |
parents | dec8cd7da4d3 |
children | c0ee73872f4e |
files | enigma/docs/source/guide.rst |
diffstat | 1 files changed, 16 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/enigma/docs/source/guide.rst Sun Jun 03 17:33:43 2012 -0500 +++ b/enigma/docs/source/guide.rst Sun Jun 03 18:35:22 2012 -0500 @@ -102,6 +102,21 @@ words, these values produce identical ring settings: ``[0, 5, 15]``, ``'A F P'``, and ``'1 6 16'``. +The second shortcut function allows you to keep your key settings stored in an +external file:: + + from enigma.machine import EnigmaMachine + + with open('my_enigma_keys.txt', 'r') as f: + machine = EnigmaMachine.from_key_file(f, day=13) + +The class method :meth:`from_key_file +<enigma.machine.EnigmaMachine.from_key_file>` builds an :class:`EnigmaMachine +<enigma.machine.EnigmaMachine>` from settings stored in a simulated monthly key +sheet file. The format of this file is explained in :doc:`keyfile`. The ``day`` +argument allows you to specify the day of the month (1-31). If this parameter is +omitted or ``None``, the day value is obtained from the current date. + Constructing by hand ~~~~~~~~~~~~~~~~~~~~ @@ -252,7 +267,7 @@ plugboard_settings='AV BS CG DL FU HZ IN KM OW RX') Suppose the Enigma operator was handed a message for transmit by an officer -which reads "The Russians are coming!". The operator would first randomly decide +which reads "The Russians are coming!" The operator would first randomly decide two things: * Initial rotor positions, say ``WXC``