RSAUtils { public static RSAPublicKey getPublicKey(String modulus, String exponent) { try { BigInteger b1 = new BigInteger(modulus); BigInteger b2 = new BigInteger(exponent); KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); RSAPublicKeySpec keySpec = new RSAPublicKeySpec(b1, b2); return (RSAPublicKey) keyFactory.generatePublic(keySpec); } catch (Exception e) { LOGGER.error("getPublicKey ex modulus={}, exponent={}", modulus, exponent, e); throw new CryptoException("Get PublicKey ex", e); } }  static Pair<RSAPublicKey, RSAPrivateKey> genKeyPair(int rsaKeySize); static String encodeBase64(Key key); static PrivateKey decodePrivateKey(String key); static PublicKey decodePublicKey(String publicKey); static String sign(byte[] data, String privateKey); static boolean verify(byte[] data, String publicKey, String sign); static RSAPublicKey getPublicKey(String modulus, String exponent); static RSAPrivateKey getPrivateKey(String modulus, String exponent); static byte[] encryptByPublicKey(byte[] data, RSAPublicKey publicKey); static byte[] decryptByPrivateKey(byte[] data, RSAPrivateKey privateKey); static byte[] decryptByPrivateKey(byte[] data, String privateKey); static byte[] decryptByPublicKey(byte[] data, String publicKey); static byte[] encryptByPublicKey(byte[] data, String publicKey); static byte[] encryptByPrivateKey(byte[] data, String privateKey); static void main(String[] args); static final int RAS_KEY_SIZE; static final String KEY_ALGORITHM; static final String KEY_ALGORITHM_PADDING; static final String SIGNATURE_ALGORITHM; }
@Test public void testGetPublicKey() throws Exception { }