mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-07 17:56:02 +08:00
Add Blowfish Algorithm (#3052)
This commit is contained in:
43
src/test/java/com/thealgorithms/ciphers/BlowfishTest.java
Normal file
43
src/test/java/com/thealgorithms/ciphers/BlowfishTest.java
Normal file
@ -0,0 +1,43 @@
|
||||
package com.thealgorithms.ciphers;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user