-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTranslationDictionary.java
More file actions
60 lines (51 loc) · 1.66 KB
/
Copy pathTranslationDictionary.java
File metadata and controls
60 lines (51 loc) · 1.66 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package io.github.vbetsch.codecracker;
import java.util.HashMap;
import java.util.Map;
import static java.util.Map.entry;
public class TranslationDictionary {
private final Map<Character, Character> decryptions = Map.ofEntries(
entry('!', 'a'),
entry(')', 'b'),
entry('"', 'c'),
entry('(', 'd'),
entry('£', 'e'),
entry('*', 'f'),
entry('%', 'g'),
entry('&', 'h'),
entry('>', 'i'),
entry('<', 'j'),
entry('@', 'k'),
entry('a', 'l'),
entry('b', 'm'),
entry('c', 'n'),
entry('d', 'o'),
entry('e', 'p'),
entry('f', 'q'),
entry('g', 'r'),
entry('h', 's'),
entry('i', 't'),
entry('j', 'u'),
entry('k', 'v'),
entry('l', 'w'),
entry('m', 'x'),
entry('n', 'y'),
entry('o', 'z')
);
private final Map<Character, Character> encryptions = invert(decryptions);
private static Map<Character, Character> invert(Map<Character, Character> map) {
Map<Character, Character> inverted = new HashMap<>();
for (Map.Entry<Character, Character> entry : map.entrySet()) {
inverted.put(entry.getValue(), entry.getKey());
}
return inverted;
}
public Map<Character, Character> getDecryptions() {
return decryptions;
}
public Map<Character, Character> getEncryptions() {
return encryptions;
}
public boolean containsDecryptionValue(char letter) {
return decryptions.containsValue(letter);
}
}