Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fynydd/fynydd.enigma
A virtual Enigma Machine that enciphers and deciphers UTF-16 strings, and which can be used for keyless encryption in mobile, desktop, and server apps (Windows, macOS, Linux, .NET 8.0, x64, Arm64, Apple Silicon).
https://github.com/fynydd/fynydd.enigma
cipher crypto cryptography dotnet encryption enigma enigma-machine keyless keyless-cipher machine ww2
Last synced: about 3 hours ago
JSON representation
A virtual Enigma Machine that enciphers and deciphers UTF-16 strings, and which can be used for keyless encryption in mobile, desktop, and server apps (Windows, macOS, Linux, .NET 8.0, x64, Arm64, Apple Silicon).
- Host: GitHub
- URL: https://github.com/fynydd/fynydd.enigma
- Owner: fynydd
- License: mit
- Created: 2024-05-15T22:14:13.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-05-15T22:15:01.000Z (6 months ago)
- Last Synced: 2024-05-16T02:05:22.579Z (6 months ago)
- Topics: cipher, crypto, cryptography, dotnet, encryption, enigma, enigma-machine, keyless, keyless-cipher, machine, ww2
- Language: C#
- Homepage: https://fynydd.com
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# What is the Enigma Machine?
The Enigma machine is a cipher device developed and used in the early- to mid-20th century to protect commercial, diplomatic, and military communication. It was employed extensively by Nazi Germany during World War II, in all branches of the German military. The Enigma machine was considered so secure that it was used to encipher the most top-secret messages.
Learn more about it at [https://en.wikipedia.org/wiki/Enigma_machine](https://en.wikipedia.org/wiki/Enigma_machine).# The Project
This project is a virtual *Enigma Machine* that supports the entire UTF-16 character set, whereas the original German hardware only supported 26 uppercase letters (no spaces!).
Just like the physical device, machine state is used to both encipher and decipher text with the same functions (like a text toggle). This virtual version works with UTF-16 strings using a keyless algorythm based on the inner workings of the original hardware. To accomplish this, it uses a custom predictable random number generator (PRNG) to ensure the cipher will work on any supported platform.
Unlike the original hardware, you can add as many virtual rotors as you like, set the cipher seeds for all machine components (effectively randomizing the character sets they use), set starting rotor positions, and more, which will improve the overall cipher strength. Because the entire UTF-16 character set is used, the cipher strength is already exponentially better even without additional rotors, and should meet modern keyless cryptography needs.
It's easy to create a new EnigmaMachine object and encipher/decipher your own text:
```C#
var enigmaMachine = new EnigmaMachine(new EnigmaConfiguration
{
PlugBoardCipherSeed = 1234567,
ReflectorCipherSeed = 6789101,
Rotors = new List // Rotors work top to bottom; original hardware has them right to left
{
new (rotorCipherSeed: 9876543210, rotorStartingPosition: 0, advanceNextRotorIncrement: 50),
new (rotorCipherSeed: 1234567890, rotorStartingPosition: 0, advanceNextRotorIncrement: 25),
new (rotorCipherSeed: 1029384756, rotorStartingPosition: 0) // No neighbor for the last rotor to advance
}
});var message = @"
Fynydd is a software development & hosting company.
Fynydd is a Welsh word (prounounced: /ˈvənɨ̞ð/) that means mountain or hill.
";var enciphered = enigma.RunCipher(message);
var deciphered = enigma.RunCipher(enciphered);Assert.Equal(message, deciphered);
```This project is a .NET library with xUnit tests, so you can easily play with the virtual Enigma Machine.