mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-12 22:56:11 +08:00
Add ADFGVX Cipher (#5631)
This commit is contained in:

committed by
GitHub

parent
8722598434
commit
f8397bf09b
@ -0,0 +1,36 @@
|
||||
package com.thealgorithms.ciphers;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ADFGVXCipherTest {
|
||||
|
||||
ADFGVXCipher adfgvxCipher = new ADFGVXCipher();
|
||||
|
||||
@Test
|
||||
void adfgvxCipherEncryptTest() {
|
||||
// given
|
||||
String message = "attack at 1200am"; // Plaintext message
|
||||
String keyword = "PRIVACY";
|
||||
|
||||
// when
|
||||
String cipherText = adfgvxCipher.encrypt(message, keyword);
|
||||
|
||||
// then
|
||||
assertEquals("DGDDDAGDDGAFADDFDADVDVFAADVX", cipherText);
|
||||
}
|
||||
|
||||
@Test
|
||||
void adfgvxCipherDecryptTest() {
|
||||
// given
|
||||
String cipherText = "DGDDDAGDDGAFADDFDADVDVFAADVX"; // Ciphertext message
|
||||
String keyword = "PRIVACY";
|
||||
|
||||
// when
|
||||
String plainText = adfgvxCipher.decrypt(cipherText, keyword);
|
||||
|
||||
// then
|
||||
assertEquals("ATTACKAT1200AM", plainText);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user