This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0. speech | |
1. shout | |
2. yell | |
3. battle_cry | |
4. children_shouting | |
5. screaming | |
6. whispering | |
7. laughter | |
8. baby_laughter | |
9. giggling |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
▿ 1303 elements | |
- 0 : "abacus" | |
- 1 : "accordion" | |
- 2 : "acorn" | |
- 3 : "acrobat" | |
- 4 : "adult" | |
- 5 : "adult_cat" | |
- 6 : "agriculture" | |
- 7 : "aircraft" | |
- 8 : "airplane" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Atbash: Cipher { | |
private let alphabet = Alphabet.letters | |
func encrypt(_ text: String) -> String { | |
var output = [Character]() | |
for character in text { | |
if character != " " { | |
guard let index = alphabet.index(of: character) else { continue } | |
output.append(alphabet[alphabet.count - index - 1]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func encrypt() { | |
outputLabel.text = cipher?.encrypt(inputTextView.text) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func selectCipher(_ sender: UISegmentedControl) { | |
guard let cipherName = CipherName(rawValue: sender.selectedSegmentIndex) else { return } | |
switch cipherName { | |
case .atbash: | |
encryptButton.isEnabled = true | |
decryptButton.isEnabled = true | |
default: | |
encryptButton.isEnabled = false | |
decryptButton.isEnabled = false | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func selectCipher(_ sender: UISegmentedControl) { | |
guard let cipherName = CipherName(rawValue: sender.selectedSegmentIndex) else { return } | |
switch cipherName { | |
case .atbash: | |
break | |
default: | |
break | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NumbersDecryptor: Decryptor { | |
fileprivate var cipherDictionary = [String : String]() | |
override func decrypt(_ input: String) -> String? { | |
cipherDictionary.removeAll() | |
// The most annoying part of this is to properly replace characters in message | |
// so when we do .separatedBy we just get strings we can change to numbers. | |
// This may break depending on what text you will use and whether you are using characters | |
// that are currently supported or not. I even noticed that – is not the same as -. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AtbashDecryptor: Decryptor { | |
override func substitute(_ string: String) -> String { | |
guard let index = alphabet.index(of: string) else { return string } | |
return alphabet[alphabet.count - index - 1] | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let s01e01Encrypted = "ZHOFRPH WR JUDYLWB IDOOV" | |
let s01e01Decrypted = ShiftLettersDecryptor(shift: -3).decrypt(s01e01Encrypted) | |
print(s01e01Decrypted!) // welcome to gravity falls |
NewerOlder