-
Notifications
You must be signed in to change notification settings - Fork 0
yenigma.py
pythonian23 edited this page Sep 3, 2020
·
9 revisions
- imports
warnings,Unionfromtyping, andrandomish
| method | description |
|---|---|
__init__ |
init method for Yenigma |
set_base |
creates a basic set |
create_rotors |
creates a set of rotors |
create_rotor |
creates a singular rotor |
create_reflector |
creates reflector |
rotor_f |
returns a value through the rotor |
rotor_b |
reverse direction of rotor_f
|
reflect |
returns a value through the reflector |
rotate |
rotates a rotor |
- init method for Yenigma
- sets a default set of rotors
- sets the base ring set to
ring_set, alphabet is default - saves the number of rings
- sets up
rotors - creates
reflector - ties rotors and reflectors together in
full_set
- checks for correct format and returns an error if it is not in the correct format
- uses
self.create_rotorto generate each key
- uses
randomish.set_seed()to make each key return a different set of rings per key - uses
randomish.random_int()to pop a character fromtemp_charsand appends the character totemp_rotor - saves
temp_rotortoself.rotors
- uses
randomish.set_seed()to make each key return a different set of rings per key - creates a reflector by selecting two random numbers that could be equal, and deleting them from
temp_char
- checks if
charis a valid character and returns an empty string if it isn't - if
charis valid, returns the swapped character from the selectedring
- checks if
charis a valid character and returns an empty string if it isn't - if
charis valid, returns the swapped character from the selectedring - reverse of
rotor_f
- same as
rotor_forrotor_b, but with the reflector - returns
None
- rotates the selected
ringby the requested quantity -
quantity's default is1 - does not change
self.rotation; must be done separately