Add Blowfish Algorithm (#3052)

This commit is contained in:
Akshay Dubey
2022-05-18 22:59:31 +05:30
committed by GitHub
parent 239b274069
commit f9b788f7f4
2 changed files with 459 additions and 0 deletions

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