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

committed by
GitHub

parent
c56d282ae0
commit
87030aff1e
@ -0,0 +1,34 @@
|
||||
package com.thealgorithms.ciphers;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class BaconianCipherTest {
|
||||
|
||||
BaconianCipher baconianCipher = new BaconianCipher();
|
||||
|
||||
@Test
|
||||
void baconianCipherEncryptTest() {
|
||||
// given
|
||||
String plaintext = "MEET AT DAWN";
|
||||
|
||||
// when
|
||||
String cipherText = baconianCipher.encrypt(plaintext);
|
||||
|
||||
// then
|
||||
assertEquals("ABBAAAABAAAABAABAABBAAAAABAABBAAABBAAAAABABBAABBAB", cipherText);
|
||||
}
|
||||
|
||||
@Test
|
||||
void baconianCipherDecryptTest() {
|
||||
// given
|
||||
String ciphertext = "ABBAAAABAAAABAABAABBAAAAABAABBAAABBAAAAABABBAABBAB";
|
||||
|
||||
// when
|
||||
String plainText = baconianCipher.decrypt(ciphertext);
|
||||
|
||||
// then
|
||||
assertEquals("MEETATDAWN", plainText);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user