Add ADFGVX Cipher (#5631)

This commit is contained in:
Benjamin Burstein
2024-10-12 03:34:49 -04:00
committed by GitHub
parent 8722598434
commit f8397bf09b
2 changed files with 159 additions and 0 deletions

View File

@ -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);
}
}