enigma¶
Welcome to enigma’s documentation!¶
The Enigma Machine¶
Some text about the Enigma machine.
API Reference¶
This page contains auto-generated API reference documentation 1.
enigma
¶
Submodules¶
enigma.__main__
¶
Run enigma.
|
Listen for keyboard input, output Enigma encoded letter immediately. |
- enigma.__main__.main()¶
Listen for keyboard input, output Enigma encoded letter immediately.
enigma.enigma
¶
An Enigma machine.
An Enigma machine. |
|
A single rotor for scrambling an input pin to a different output. |
- enigma.enigma.ROTOR_LEN¶
- class enigma.enigma.Enigma¶
An Enigma machine.
- press_key(self, letter_input)¶
Press a key on the machine.
- Parameters
letter_input (str) – the key pressed
- Returns
the letter bulb that lights up
- Return type
str
- step_rotors(self)¶
Step rotors forward.
Step first rotor, turning over rotors 2 and 3 if required.
- class enigma.enigma.Rotor(wiring, turnover_notch_letter)¶
A single rotor for scrambling an input pin to a different output.
- wire_up(self, output_letter_order)¶
Wire up the rotor.
Create a dict to implement the input/output wiring of the rotor pins. For example: “0”: “7”, “1”: “17”, “2”: “2” :param output_letter_order: order of the 26 output pins :type output_letter_order: str
- step(self)¶
Advance the rotor by one.
- trace(self, input_pin_pos0)¶
Trace an input pin through the rotor to an output pin.
- Parameters
input_pin_pos0 (int) – input pin from the previous component (machine or previous rotor) relative to position 0 of the rotor
- Returns
output pin relative to position 0 of rotor
- Return type
int
enigma.keyer
¶
A Morse code keyer.
A Morse “key” is a device with a button used to encode the carrier wave with a Morse signal. Morse operators use these to produce the familiar “dits” and “dahs” of Morse code. The Keyer class converts dots and dashes into an encoded carrier waveform and plays it audibly.
Convert Morse code to audio and play it. |
- enigma.keyer.MORSE_DIT_FREQ = 10¶
- enigma.keyer.MORSE_DIT = 1¶
- enigma.keyer.MORSE_DAH = 3¶
- enigma.keyer.FREQUENCY = 440¶
- enigma.keyer.SAMPLE_RATE = 44100¶
- class enigma.keyer.Keyer(morse)¶
Convert Morse code to audio and play it.
- create_binary_signal(self, morse)¶
Converts Morse code into a binary signal.
For example, “.- .” becomes “1011100001” :param morse: dot-and-dash Morse code :type morse: str :return: binary Morse code signal :rtype: np.ndarray
- convert_audio(self)¶
Convert binary signal to audio.
Encode sine wave with binary signal and create playable audio. :return: 16-bit audio waveform :rtype: np.ndarray
- play(self)¶
Play Morse code.
In the case of audio errors (i.e. on CI system with no sound card), catch exception and notify.
enigma.morse
¶
A Morse code encoder and decoder.
Morse code consists of “dits”, “dahs” and spaces. A dit or dah is a signal, whereas a space is an absensce of signal. A dit is one unit of Morse time (or beat) a dah is three. Each dit or dah is followed by a space of one dit. Each character is followed by a space of three dits, and words are separated by a space of seven dits.
Morse code encoder/decoder. |
- enigma.morse.MORSE_CODE¶
- enigma.morse.MORSE_CHAR_SPACE¶
- enigma.morse.MORSE_WORD_SPACE¶
- class enigma.morse.Morse¶
Morse code encoder/decoder.
- encode(self, text)¶
Encode the input text to Morse.
- Parameters
text (str) – text to convert to Morse
- decode(self, morse)¶
Decode input Morse to text.
- Parameters
morse (str) – input Morse code
- decode_words(self, morse_words)¶
Decode a list of Morse words.
- Parameters
morse_words (list) – list of Morse words
- decode_letters(self, morse_letters)¶
Decode a list of Morse letters.
- Parameters
morse_letters (list) – list of Morse letters
- 1
Created with sphinx-autoapi