@DisplayName("test_decrypt") @Test void testDecrypt() { byte[] encryptData = rsaCipher.encrypt("我是ukuz😄".getBytes(StandardCharsets.UTF_8)); byte[] decryptData = rsaCipher.decrypt(encryptData); assertEquals("我是ukuz😄", new String(decryptData, StandardCharsets.UTF_8)); }
@Override public byte[] decrypt(byte[] encryptData) { try { javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance(KEY_ALGORITHM); cipher.init(javax.crypto.Cipher.DECRYPT_MODE, privateKey); byte[] result = cipher.doFinal(Base64.getDecoder().decode(encryptData)); return result; } catch (Exception e) { throw new CryptoException(e); } }
RSACipher implements Cipher { @Override public byte[] decrypt(byte[] encryptData) { try { javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance(KEY_ALGORITHM); cipher.init(javax.crypto.Cipher.DECRYPT_MODE, privateKey); byte[] result = cipher.doFinal(Base64.getDecoder().decode(encryptData)); return result; } catch (Exception e) { throw new CryptoException(e); } } }
RSACipher implements Cipher { @Override public byte[] decrypt(byte[] encryptData) { try { javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance(KEY_ALGORITHM); cipher.init(javax.crypto.Cipher.DECRYPT_MODE, privateKey); byte[] result = cipher.doFinal(Base64.getDecoder().decode(encryptData)); return result; } catch (Exception e) { throw new CryptoException(e); } } RSACipher(String publicKey, String privateKey);  RSACipher(PublicKey publicKey, PrivateKey privateKey, KeyFactory keyFactory); }
RSACipher implements Cipher { @Override public byte[] decrypt(byte[] encryptData) { try { javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance(KEY_ALGORITHM); cipher.init(javax.crypto.Cipher.DECRYPT_MODE, privateKey); byte[] result = cipher.doFinal(Base64.getDecoder().decode(encryptData)); return result; } catch (Exception e) { throw new CryptoException(e); } } RSACipher(String publicKey, String privateKey);  RSACipher(PublicKey publicKey, PrivateKey privateKey, KeyFactory keyFactory); @Override byte[] decrypt(byte[] encryptData); @Override byte[] encrypt(byte[] originData); @Override String toString(); }
RSACipher implements Cipher { @Override public byte[] decrypt(byte[] encryptData) { try { javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance(KEY_ALGORITHM); cipher.init(javax.crypto.Cipher.DECRYPT_MODE, privateKey); byte[] result = cipher.doFinal(Base64.getDecoder().decode(encryptData)); return result; } catch (Exception e) { throw new CryptoException(e); } } RSACipher(String publicKey, String privateKey);  RSACipher(PublicKey publicKey, PrivateKey privateKey, KeyFactory keyFactory); @Override byte[] decrypt(byte[] encryptData); @Override byte[] encrypt(byte[] originData); @Override String toString(); static final String KEY_ALGORITHM; }