Add Polybius Cipher (#3185)

This commit is contained in:
Hikmet Çakır
2022-07-11 18:15:14 +03:00
committed by GitHub
parent f7bd7682ba
commit 199c85d191
2 changed files with 104 additions and 0 deletions

View File

@ -0,0 +1,45 @@
package com.thealgorithms.ciphers;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class PolybiusTest {
@Test
void testEncrypt() {
// Given
String plaintext = "HELLOWORLD";
// When
String actual = Polybius.encrypt(plaintext);
// Then
assertEquals("12042121244124322103", actual);
}
@Test
void testDecrypt() {
// Given
String ciphertext = "12042121244124322103";
// When
String actual = Polybius.decrypt(ciphertext);
// Then
assertEquals("HELLOWORLD", actual);
}
@Test
void testIsTextTheSameAfterEncryptionAndDecryption() {
// Given
String plaintext = "HELLOWORLD";
// When
String encryptedText = Polybius.encrypt(plaintext);
String actual = Polybius.decrypt(encryptedText);
// Then
assertEquals(plaintext, actual);
}
}