mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-08 10:15:51 +08:00
Add unit test for RSA cipher (#3664)
This commit is contained in:

committed by
GitHub

parent
f8897f166d
commit
8c6ed9c240
24
src/test/java/com/thealgorithms/ciphers/RSATest.java
Normal file
24
src/test/java/com/thealgorithms/ciphers/RSATest.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.thealgorithms.ciphers;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class RSATest {
|
||||
|
||||
RSA rsa = new RSA(1024);
|
||||
|
||||
@Test
|
||||
void testRSA() {
|
||||
// given
|
||||
String textToEncrypt = "Such secure";
|
||||
|
||||
// when
|
||||
String cipherText = rsa.encrypt(textToEncrypt);
|
||||
String decryptedText = rsa.decrypt(cipherText);
|
||||
|
||||
// then
|
||||
assertEquals("Such secure", decryptedText);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user