Add autokey cipher (#5569)

This commit is contained in:
Benjamin Burstein
2024-10-06 01:37:56 -04:00
committed by GitHub
parent f34fe4d840
commit 07cb6c46a8
2 changed files with 91 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 AutokeyCipherTest {
Autokey autokeyCipher = new Autokey();
@Test
void autokeyEncryptTest() {
// given
String plaintext = "MEET AT DAWN";
String keyword = "QUEEN";
// when
String cipherText = autokeyCipher.encrypt(plaintext, keyword);
// then
assertEquals("CYIXNFHEPN", cipherText);
}
@Test
void autokeyDecryptTest() {
// given
String ciphertext = "CYIX NF HEPN";
String keyword = "QUEEN";
// when
String plainText = autokeyCipher.decrypt(ciphertext, keyword);
// then
assertEquals("MEETATDAWN", plainText);
}
}