RSA4K

A RSA Cipher implementation for Kotlin/Java.

Discord

GitHub last commit GitHub commit activity GitHub code size in bytes GitHub contributors

Usage

Import

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
  1. Go to the release page.
  2. Download RSA4K-${version}-all.jar.
  3. Add the jar to your classpath.

Example

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")
}

Documentation

You can find the documentation here.

Code Quality Monitoring

You can find the qodana report here.

Bugs and Suggestions

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.

Disclaimer

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.

GitHub

View Github