Search code examples
javaopen-sourcersa

RSA algorithm library for Java


I want to provide my application with simple licensing mechanism based on RSA algorithm.

Are there any free RSA libraries?


Solution

  • Just use the javax.crypto and java.security packages. It's in the Java standard platform.

    KeyPair keys = KeyPairGenerator.getInstance("RSA").generateKeyPair();
    Cipher cipher = Cipher.getInstance("RSA");
    cipher.init(Cipher.ENCRYPT_MODE, keys.getPublic());
    byte[] encrypted = cipher.doFinal(rawData);
    

    Links for the official documentation: