Coder Social home page Coder Social logo

robert-van-engelen / enigma Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 1.0 185 KB

A historically accurate Enigma machine in your pocket to encode and decode secret messages

License: BSD 3-Clause "New" or "Revised" License

BASIC 100.00%
pocketcomputer enigma-simulator

enigma's Introduction

Enigma

An Enigma machine for SHARP pocket computers.

PC-2500

This program was written as a result of a class project on cyber security. I thought it would be fun to rewrite in BASIC to run on SHARP pocket computers.

Recommended reading:

The program is written from scratch and does not use any code from any existing Enigma simulators.

The program accurately simulates the Enigma I machine UKW B and C with 5 rotors I to V. It has been tested with real WW2 secret messages.

The program runs on SHARP PC-1350/1360/2500. A slimmed-down version runs on SHARP PC-126x/1475.

Instructions

RUN initializes the system, which takes a few seconds. Then it will ask if you want to print the output PRINT (y/N). If you reply Y[ENTER] then the system will ask PRINT KEYS (Y/n). Reply Y[ENTER] to print secret keys, which is not recommended if you want to keep your secret keys a secret. Optionally you can print a heading text HEADING TEXT TO PRINT? by typing it in followed by [ENTER], which will be printed as a heading. You can use this to add information for the recipient.

Next you will need to specify the Enigma UKW, enter B (default) or C.

There are five steps that can be executed in order, or individually selected from the menu, or selected at any time with a DEF key:

  1. DEF-A: select plugboard settings by entering pairs of letters
  2. DEF-B: select scramblers, left-to-right, specified by three numbers 1 to 5
  3. DEF-C: specify ring settings, left-to-right, enter three letters
  4. DEF-D: specify starting position, left-to-right, enter three letters
  5. DEF-X: enter the text to encode or decode

DEF-SPACE returns to the menu.

Example decryption

This message deciphering example follows the operating procedure performed by an Enigma operator (the full deciphering is not shown but replaced with .....). Each value input is followed by [ENTER]. Text to decipher can be entered with spaces to group letters, but spacing is ignored and is not required.

ENIGMA UKW (B/C) B                   (Enigma B type)
STECKERVERBINDUNG PO                 (plugboard settings)
STECKERVERBINDUNG ML
STECKERVERBINDUNG IU
STECKERVERBINDUNG KJ
STECKERVERBINDUNG NH
STECKERVERBINDUNG YT
STECKERVERBINDUNG GB
STECKERVERBINDUNG VF
STECKERVERBINDUNG RE
STECKERVERBINDUNG DC
STECKERVERBINDUNG [ENTER]
WALZENLAGE 125                       (scrambler arrangement)
RINGSTELLUNG FVN                     (scrambler orientation)
GRUNDSTELLUNG EHZ                    (start position to retrieve message key)
?TBS                                 (decrypt the message key)
XWB                                  (the message key to decrypt text)
[DEF-D]
GRUNDSTELLUNG XWB                    (start position to decrypt text)
?QBLTW LDAHH YEOEF PTWYB
DERFU ..... ..... .....
?LENDP MKOXL DFAMU DWIJD
KAMPF ..... ..... .....
?XRJZ
ITZX
?[ENTER]
END

Example encryption

This message encoding example follows the operating procedure performed by an Enigma operato (the full ciphertext is not shown). Each value input is followed by [ENTER]. Text to decipher can be entered with spaces to group letters, but spacing is ignored and is not required.

Note that the random start position key and encrypted message key are shared with the receiver by including EHZ TBS in the message sent. To do so, enable print and include EHZ in the print heading text. TBS is printed as the cipher of the plain message key XWB entered as text to encrypt. The heading text may also be used to send the key identification group of five letters.

ENIGMA UKW (B/C) B                   (Enigma B type)
STECKERVERBINDUNG PO                 (plugboard settings)
STECKERVERBINDUNG ML
STECKERVERBINDUNG IU
STECKERVERBINDUNG KJ
STECKERVERBINDUNG NH
STECKERVERBINDUNG YT
STECKERVERBINDUNG GB
STECKERVERBINDUNG VF
STECKERVERBINDUNG RE
STECKERVERBINDUNG DC
STECKERVERBINDUNG [ENTER]
WALZENLAGE 125                       (scrambler arrangement)
RINGSTELLUNG FVN                     (scrambler orientation)
GRUNDSTELLUNG EHZ                    (randomly selected start position key to share)
?XWB                                 (randomly selected message key)
TBS                                  (encrypted message key to share)
[DEF-D]
GRUNDSTELLUNG XWB                    (start position to encrypt text)
?.....
?[ENTER]
END

A challenge

To learn how to use an Enigma machine in general, try the "Authentic Wartime Message from the Russian Front" published in the Enigma cipher machine simulator manual.

How to load

Play the wav file to CLOAD on your pocket computer.

The excellent PocketTools are used to convert BASIC source code to wav files:

bas2img --pc=1350 --level=8 enigma.bas
bin2wav --pc=1350 enigma.img

Author: Dr. Robert A. van Engelen

enigma's People

Contributors

robert-van-engelen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

icodein

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.