Coder Social home page Coder Social logo

enigma-java's Introduction

A simple simulation of an Enigma machine. You provide an encrypted message and
this will try all the different combinations of rotors, reflectors, and starting
positions to find the proper key. The messages and decrypes will be in ALL CAPS
with no spaces.

To determine which solution is correct this does a letter frequency analysis
and a digraph frequency analysis on the dycrypted message. Using the known
frequency of letters and digraphs in the English language, this assigns a score
to each decryption. The messages with the lowest scores are kept and displayed.
In my experiments, on a message of 80 characters is more than enough to make a
very good guess. Very short messages are much harder.

This was built using an Enigma simulator from
http://enigmaco.de/enigma/enigma.html as an oracle. The rotor mappings and
other information was taken from the Enigma and Enigma Rotor wikipedia pages.

http://en.wikipedia.org/wiki/Enigma_machine
http://en.wikipedia.org/wiki/Enigma_rotor_details

The letter frequencies used in the frequency analysis can be found in the
Letter frequency wikipedia article.
http://en.wikipedia.org/wiki/Letter_frequencies

To build use:
$ gradle clean test
$ gradle shadowJar

To run use:
$ java -jar build/libs/enigma-java-0.1-all.jar

The program takes a variety of arguments:
-message: Message is a required argument, it is the encrypted message to break.
-crib: If you have a crib, a known word in the decrypted message, you can
provide it to help identify the proper decoded message.
-rotors: The rotors to use. This should be a comma separated list. By default
the value is "1,2,3,4 5". If you know the message doesn't use rotor 4, then you
can reduce the number of combinations tried by changing rotors to "1,2,3,5".
-reflectors: Same as rotors, but which reflectors to use. By default this is
"A,B,C", but the simulator linked above only uses rotor B, so you can speed up
processing a lot by only specifying B.
-results: The number of results to display. By default this is 3.
-num_threads: The number of threads to use while processing. By default this is
8.

Some sample messages you can try are:
ZTQBLVXKPBPGAVQBRYDYQEZNKRLMZTMRGBJSQKHDPHHNTNIDLYVFCOKZYYSMJFAHQBTEAVFKOXRPSQX
which decrypts to
THISISASLIGHTLYLONGERTESTSOIHAVETOSEEIFICANKEEPWRITINGALONGERSTRINGTOUSEASINPUT
with KEY=AAB
Rotors: 1, 2, 3
Reflector: B

PCSONKFYSIQHZJCVFLPAWUWTXWYNWPTCCLOJNNKNCNECAAQPYNEWIFHVDZQIWYTXMEQQMZ
which decrypts to
IDONTREALLYKNOWWHATTHISMESSAGEISGOINGTOSAYBUTIMGOINGTOKEEPTYPINGANYWAY
with KEY=TJB
Rotors: 5, 1, 4
Reflector: B


MTVZLRUGJUPYISBINSDHPNXNJVYTX
which decrypts to
THISISASHORTMESSAGENOCRACKING
with KEY: TJB
Rotors: 3, 1, 4
Reflector: B
but only is you provide the crib SHORT

enigma-java's People

Contributors

mww avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

enigma-java's Issues

Provide .jar file as download

It would be super awesome if you could provide a pre-built jar file for download on this repo. I am sure some people would appreciate it. :-)

Would you please add a executable file.

Hi, mww

I am very interesting about this decryption program, but I do not have any experience with Java.
At the meantime I have a encrypted message "CPKJUCVAPYLWFTRYIBCPVOHVAVNJWNSEUQUNOISWWUWHJEFNUSBAVRVNNBMPECQLGCJISGHYOCQVVXVYKVWZOMFTKBMHSXLBLZIYYEBJQHYEKMBKJTLPHNHCSVANFTUQRJLXDAMLCPSNYZAYZBMFCLYMYPFXRMODTUODOFXVQMUJMBAATLYABFUMVPRDNJXILKYQXCJCHKCXZVCFSXTHUNTYZREUXVBJODKQCEKYGOXJAZTCYCMETCWQHCYAZGVWGNIRPFDUXADLEWJUMWDKTCFUFUHICPFXBADKBBLXAUIADSSJFNURSKAVQFGDWPPKLZEJGBEYVYXCPSOZESPANACFSARLWUTCQSIFRDWOCFEPWKJAEMMUEDYXPOHKIW" that is generate by http://www.enigmaco.de/enigma/enigma.swf.

I believe your program can decrypt that message. Would you please upload the file after compiled. So I can run it at my computer. Thanks for your help.

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.