-
-
Notifications
You must be signed in to change notification settings - Fork 393
/
Copy pathRSAEncTest.kt
30 lines (28 loc) · 1.17 KB
/
RSAEncTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import encryption.Caesar
import org.junit.Test
import java.util.*
class RSAEncTest {
val keyPairGenerator = RSA()
val privateKey: String = Base64.getEncoder().
encodeToString(keyPairGenerator.privateKey.encoded)
val publicKey: String = Base64.getEncoder().
encodeToString(keyPairGenerator.publicKey.encoded)
@Test
fun testWithKotlinString() {
val secretText = "Kotlin is a powerful programming language"
val encryptedValue = keyPairGenerator.encryptMessage(secretText, publicKey)
assert(keyPairGenerator.decryptMessage(encryptedValue, privateKey)==secretText)
}
@Test
fun testWithIntellIjString() {
val secretText = "InteliJ IDEA Community Edition"
val encryptedValue = keyPairGenerator.encryptMessage(secretText, publicKey)
assert(keyPairGenerator.decryptMessage(encryptedValue, privateKey)==secretText)
}
@Test
fun testWithAlgorithmjString() {
val secretText = "Algorithm-Repo"
val encryptedValue = keyPairGenerator.encryptMessage(secretText, publicKey)
assert(keyPairGenerator.decryptMessage(encryptedValue, privateKey)==secretText)
}
}