A RSA Cipher implementation for Kotlin/Java.
Replace ${version}
with the current version!
Gradle KTS
repositories {
maven("https://jitpack.io")
}
dependencies {
implementation("com.github.Lyzev:RSA4K:${version}")
}
Gradle Groovy
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.Lyzev:RSA4K:${version}'
}
Maven
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.Lyzev</groupId>
<artifactId>RSA4K</artifactId>
<version>${version}</version>
</dependency>
</dependencies>
Raw Jar
- Go to the release page.
- Download RSA4K-${version}-all.jar.
- Add the jar to your classpath.
fun main() {
val keys = RSAKeyFactory.genKeyPair()
val cipher = RSA(keys.first, keys.second)
val msg = "Test"
val encrypted = cipher.encrypt(msg.encodeToByteArray())
val decrypted = String(cipher.decrypt(encrypted!!))
println("public exponent -> ${keys.first.exp}")
println("public modulus -> ${keys.first.mod}")
println("private exponent -> ${keys.second.exp}")
println("private modulus -> ${keys.second.mod}")
println("encrypted -> $encrypted")
println("decrypted -> $decrypted")
}
You can find the documentation here.
You can find the qodana report here.
Bug reports and suggestions should be made in this repo's issue tracker using the templates provided. Please provide as much information as you can to best help us understand your issue and give a better chance of it being resolved.
Please note that this repository is for educational purposes only. There may be some security issues, because the author isn't a professional cryptologist. It's recommend to use the rsa implementation of java.