B4J Tutorial Enigma Machine (https://github.com/amirbawab/Enigma-machine-simulator)

This is not intended to take anything away from @ilan 's project here. I have also been reading up about the Enigma Machine recently and then checked what Java projects are available on Github and came across this Github project. It had the Jar available so did not have to download and compile the Java code to a Jar.



Have done a very "tiny" B4J project to kickstart the Enigma Machine (the Jar) from within B4J. Attached the B4J project and the Jar. Copy the Jar to your additional library folder, download the B4J project and then unzip it and run it.

It has a TextBox, Keyboad, and Wiring display (select from the menu "Display")

If you make changes to the Rotors, Reflector, or Plugboard then click "SAVE" for it to take effect.

Enjoy playing around with it - It will give you a reasonably good idea of how the Enigma Machine worked (rotors, reflectors, and the use of the Plugboard)

".....the best way for one to keep a secret is not to know the secret..."

1.png


2.png


3.png


B4X:
#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
#End Region

#AdditionalJar: EnigmaMachine

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
   
    Dim em As JavaObject  

End Sub

Sub AppStart (Form1 As Form, Args() As String)
'    MainForm = Form1
'    MainForm.RootPane.LoadLayout("Layout1")
'    MainForm.Show

    em.InitializeNewInstance("gui.Machine", Null)
   
   
End Sub
 

Attachments

  • EnigmaMachine.jar
    192.6 KB · Views: 98
  • b4jEnigmaMachine.zip
    1.6 KB · Views: 109
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
The end of my travels with the Enigma Machine
Have not used designer scripts to position the UI components - just stuck them on. You can neaten it up if you want to

Once started, select from the ComboBoxes:
1. Reflector to use
2. For each Rotor, the Type, Start, and Ring
3. Enter your Plug Combinations (optional) in the Plug Input boxes below the two TextAreas. IMPORTANT to use Upper Case (eg AB) - have not added code to convert from lower case to upper case should you use lower case
4. Click on "Set Configuration" to set the selected configuration
5. Use the "Keyboard"section to type in your message to be encoded - Original text will be in the left hand TextArea and Encoded text will be displayed in the right hand TextArea

Whenever you make any changes to to any of the settings - CLICK on Set Configuration for the changes to take effect before typing again.

No external jars required - only standard/core B4J libs.

Was indeed an interesting exercise.

1693035660371.png
 

Attachments

  • b4jEnigmaMachineUploaded.zip
    12.1 KB · Views: 73

Johan Schoeman

Expert
Licensed User
Longtime User
....and last but not least - a paper based Enigma Machine that is working 100%. The Input (most right) and Reflector (most left) are "hard" taped down on a carton core. The 3 x Rotors are taped in such a way so that they can be rotated as what the original Enigma Machine was doing.

This is assembled with Reflector B (most left), Rotors I( 2nd from the left), II(3rd from the left), and III (2nd from the right), and the Input terminal (1st from the right). A nice project for kids to do for a "show-and-tell".


1693061647550.png
 
Last edited:
Top