Commit e3949f82 authored by yazan.halloul's avatar yazan.halloul

test DES Algorithm Class

parent a5c00a27
......@@ -7,6 +7,14 @@
<groupId>org.example</groupId>
<artifactId>Yazan_Sync_Thread</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>17</maven.compiler.source>
......
import junit.framework.TestCase;
import benefit_classes.DESAlgorithm;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
public class DESTest extends TestCase {
DESAlgorithm desAlgorithm = new DESAlgorithm("fzI0SlHWAfc=");
public void testEncryptionAndDecryption() throws NoSuchPaddingException, UnsupportedEncodingException,
IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
String text = "input text to test encryption";
String encryptedText = desAlgorithm.encryption(text);
String decryptedText = desAlgorithm.decryption(encryptedText);
assertEquals(text, decryptedText);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment