-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrypKey.java
More file actions
46 lines (38 loc) · 1.03 KB
/
CrypKey.java
File metadata and controls
46 lines (38 loc) · 1.03 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
package crypSwing;
import java.util.ArrayList;
import java.util.List;
/**
* This class represents an entire key:
* the many known ciphertext characters and their plaintext.
*
* @author Aaron Bitman
* @version 1.0 03/20/19
* @version 2.0 01/20/21
*/
public class CrypKey {
/**
* Holds a list of known-key entries
*/
List <CrypKeyEntry> keyEntries = new ArrayList<>();
/**
* Adds an entry to the key.
* @param entry The entry to enter into the key
*/
void addEntry (CrypKeyEntry entry) {
CrypKeyEntry localEntry = new CrypKeyEntry();
localEntry.setCrypKeyEntry(entry.getIndex(), entry.getPlainText());
keyEntries.add(localEntry);
}
/**
* Determines whether a plaintext word conforms to the key.
* @param plainText The plaintext word
* @return true if the plaintext conforms to the key, false otherwise
*/
boolean conforms (String plainText) {
for (CrypKeyEntry temp : keyEntries) {
if (!temp.conforms(plainText))
return false;
}
return true;
}
}