Skip to content

Instantly share code, notes, and snippets.

@nielsutrecht
nielsutrecht / RsaExample.java
Created Dec 28, 2016
Example of RSA generation, sign, verify, encryption, decryption and keystores in Java
View RsaExample.java
import javax.crypto.Cipher;
import java.io.InputStream;
import java.security.*;
import java.util.Base64;
import static java.nio.charset.StandardCharsets.UTF_8;
public class RsaExample {
public static KeyPair generateKeyPair() throws Exception {
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");