- Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathPlayfairTest.java
37 lines (27 loc) · 1.05 KB
/
PlayfairTest.java
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
packagecom.thealgorithms.ciphers;
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
importorg.junit.jupiter.api.Test;
publicclassPlayfairTest {
@Test
publicvoidtestEncryption() {
PlayfairCipherplayfairCipher = newPlayfairCipher("KEYWORD");
Stringplaintext = "HELLO";
StringencryptedText = playfairCipher.encrypt(plaintext);
assertEquals("GYIZSC", encryptedText);
}
@Test
publicvoidtestDecryption() {
PlayfairCipherplayfairCipher = newPlayfairCipher("KEYWORD");
StringencryptedText = "UDRIYP";
StringdecryptedText = playfairCipher.decrypt(encryptedText);
assertEquals("NEBFVH", decryptedText);
}
@Test
publicvoidtestEncryptionAndDecryption() {
PlayfairCipherplayfairCipher = newPlayfairCipher("KEYWORD");
Stringplaintext = "PLAYFAIR";
StringencryptedText = playfairCipher.encrypt(plaintext);
StringdecryptedText = playfairCipher.decrypt(encryptedText);
assertEquals(plaintext, decryptedText);
}
}