Skip to content

Instantly share code, notes, and snippets.

@KentaKudo
Created July 19, 2017 19:59
Show Gist options
  • Save KentaKudo/6ca447eb015bdb1d27a4063a44393406 to your computer and use it in GitHub Desktop.
Save KentaKudo/6ca447eb015bdb1d27a4063a44393406 to your computer and use it in GitHub Desktop.
// rotor
let ETW_K: Cipher = { token in
switch token {
case .A: return .Q
case .B: return .W
case .C: return .E
case .D: return .R
case .E: return .T
case .F: return .Z
case .G: return .U
case .H: return .I
case .I: return .O
case .J: return .A
case .K: return .S
case .L: return .D
case .M: return .F
case .N: return .G
case .O: return .H
case .P: return .J
case .Q: return .K
case .R: return .P
case .S: return .Y
case .T: return .X
case .U: return .C
case .V: return .V
case .W: return .B
case .X: return .N
case .Y: return .M
case .Z: return .L
}
}
// plugboard
let plugboard: Cipher = { token in
switch token {
case .A: return .D
case .B: return .P
case .C: return .L
case .D: return .A
case .E: return .X
case .H: return .M
case .J: return .S
case .K: return .O
case .L: return .C
case .M: return .H
case .N: return .Z
case .O: return .K
case .P: return .B
case .Q: return .Y
case .S: return .J
case .U: return .W
case .W: return .U
case .X: return .E
case .Y: return .Q
case .Z: return .N
default:
return token
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment