Add BaconianCipher (#5932)

This commit is contained in:
Benjamin Burstein
2024-10-22 14:30:37 -04:00
committed by GitHub
parent c56d282ae0
commit 87030aff1e
2 changed files with 105 additions and 0 deletions

View File

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