mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-28 23:15:17 +08:00
39 lines
888 B
Java
39 lines
888 B
Java
package com.thealgorithms.ciphers;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
class BlowfishTest {
|
|
|
|
Blowfish blowfish = new Blowfish();
|
|
|
|
@Test
|
|
void testEncrypt() {
|
|
// given
|
|
String plainText = "123456abcd132536";
|
|
String key = "aabb09182736ccdd";
|
|
String expectedOutput = "d748ec383d3405f7";
|
|
|
|
// when
|
|
String cipherText = blowfish.encrypt(plainText, key);
|
|
|
|
// then
|
|
assertEquals(expectedOutput, cipherText);
|
|
}
|
|
|
|
@Test
|
|
void testDecrypt() {
|
|
// given
|
|
String cipherText = "d748ec383d3405f7";
|
|
String key = "aabb09182736ccdd";
|
|
String expectedOutput = "123456abcd132536";
|
|
|
|
// when
|
|
String plainText = blowfish.decrypt(cipherText, key);
|
|
|
|
// then
|
|
assertEquals(expectedOutput, plainText);
|
|
}
|
|
}
|