mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-07 17:56:02 +08:00
Add autokey cipher (#5569)
This commit is contained in:

committed by
GitHub

parent
f34fe4d840
commit
07cb6c46a8
36
src/test/java/com/thealgorithms/ciphers/AutokeyTest.java
Normal file
36
src/test/java/com/thealgorithms/ciphers/AutokeyTest.java
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user