Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mikaoj/enigmakit

Enigma encryption in Swift
https://github.com/mikaoj/enigmakit

cipher encryption enigma enigma-machine enigma-simulator swift

Last synced: 8 days ago
JSON representation

Enigma encryption in Swift

Awesome Lists containing this project

README

        

# ๐•ฐ๐–“๐–Ž๐–Œ๐–’๐–†๐•ถ๐–Ž๐–™

[![CI Status](http://img.shields.io/travis/mikaoj/EnigmaKit.svg?style=flat)](https://travis-ci.org/mikaoj/EnigmaKit)
[![Version](https://img.shields.io/cocoapods/v/EnigmaKit.svg?style=flat)](http://cocoapods.org/pods/EnigmaKit)
[![License](https://img.shields.io/cocoapods/l/EnigmaKit.svg?style=flat)](http://cocoapods.org/pods/EnigmaKit)
[![Platform](https://img.shields.io/cocoapods/p/EnigmaKit.svg?style=flat)](http://cocoapods.org/pods/EnigmaKit)
![Alt text](enigma.gif "Enigma")

## ๐–€๐–˜๐–†๐–Œ๐–Š
```swift
// Will create an Enigma with an empty plugboard, rotors I, II, III and reflector B (wide).
let enigma = Enigma()
// Will output "ILBDA AMTAZ"
let result = enigma.encode("HELLO WORLD")
```

```swift
let enigma = Enigma()
// "HELLO WORLD"
let result = enigma.encode("ILBDA AMTAZ")
```
## ๐•ฎ๐–”๐–’๐–•๐–”๐–“๐–Š๐–“๐–™๐–˜
#### ๐•ป๐–‘๐–š๐–Œ๐–‡๐–”๐–†๐–—๐–‰
```swift
// Create a plugboard and add a patch between A and D
let plugboard = Plugboard()
plugboard.add(("A", "D"))
```
#### ๐•ฝ๐–”๐–™๐–”๐–—
```swift
// III rotor. EnigmaKit comes prebuilt with rotors I-VIII
let rotor = Rotor.III
rotor.setting = 5 // Ringstellung
rotor.position = 6 // Grundstellung

// Or initialize your own
let rotor = Rotor(name: "My custom rotor", wiring: "VZBRGITYUPSDNHLXAWMJQOFECK", notch: "QV")
```
#### ๐•ฝ๐–Š๐–‹๐–‘๐–Š๐–ˆ๐–™๐–”๐–—
```swift
// EnigmaKit comes with reflectors A-C (wide) and B-C (thin)
let reflector = Reflector.B

// Or you can create your own reflector
let reflector = Reflector(name: "My custom reflector", wiring: "VZBRGITYUPSDNHLXAWMJQOFECK")
```
#### ๐•ฐ๐–“๐–Ž๐–Œ๐–’๐–†
```swift
// Create an enigma with your own plugboard, rotors and reflector of choice
let enigma = Enigma(reflector: Reflector.C, rotors: [Rotor.III, Rotor.IV, Rotor.II], plugboard: Plugboard())
```

## ๐•ฝ๐–Š๐––๐–š๐–Ž๐–—๐–Š๐–’๐–Š๐–“๐–™๐–˜
Don't mention the war

## ๐•ด๐–“๐–˜๐–™๐–†๐–‘๐–‘๐–†๐–™๐–Ž๐–”๐–“

EnigmaKit is available through [Swift Package Manager](https://swift.org/package-manager/), [CocoaPods](http://cocoapods.org).

## ๐•ฌ๐–š๐–™๐–๐–”๐–—

Joakim Gyllstrรถm, [email protected]

## ๐•ท๐–Ž๐–ˆ๐–Š๐–“๐–˜๐–Š

EnigmaKit is available under the MIT license. See the LICENSE file for more info.