Add this to your pom.xml and run mvn install
<dependency>
<groupId>de.mctzock</groupId>
<artifactId>keys</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
package org.example.examplepackage;
import de.mctzock.keys.RSAKeys;
import java.security.KeyPair;
public class Main {
public static void main(String[] args) {
// generate key pair
KeyPair keyPair = RSAKeys.gen(2048); // size of keys
// encrypt message
byte[] encrypted = RSAKeys.encrypt("Hello World!", keyPair.getPublic());
// decrypt message
String decrypted = RSAKeys.decrypt(encrypted, keyPair.getPrivate());
// For more (e.g. reading keys from file) please view the java docs
}
}
The JavaDocs can be found here