RSA { protected RSA() { } protected  RSA(); static RsaKeyPair generateKeyPair(); static String encodePrivateKey(RSAPrivateKey key); static String encodePublicKey(RSAPublicKey key); static RSAPrivateKey decodePrivateKey(String base64); static RSAPublicKey decodePublicKey(String base64); static final String ALGORITHM; static final int DEFAULT_KEY_SIZE; }
@Test public void testRsa() { RsaKeyPair kp = RSA.generateKeyPair(); String privateKeyBase64 = kp.getBase64PrivateKey(); String publicKeyBase64 = kp.getBase64PublicKey(); RSAPrivateKey privateKey = RSA.decodePrivateKey(privateKeyBase64); RSAPublicKey publicKey = RSA.decodePublicKey(publicKeyBase64); assertEquals(privateKeyBase64, RSA.encodePrivateKey(privateKey)); assertEquals(publicKeyBase64, RSA.encodePublicKey(publicKey)); }