@DisplayName("test_decrypt") @Test void testDecrypt() { byte[] encryptData = aesCipher.encrypt("我叫ukuz!".getBytes(StandardCharsets.UTF_8)); byte[] decryptData = aesCipher.decrypt(encryptData); assertEquals("我叫ukuz!", new String(decryptData)); }
@Override public byte[] decrypt(byte[] encryptData) { Properties properties = new Properties(); try (ByteArrayInputStream inputStream = new ByteArrayInputStream(encryptData); CryptoInputStream cis = new CryptoInputStream(KEY_ALGORITHM_TRANSFORM, properties, inputStream, key, iv)) { byte[] decryptedData = new byte[cis.available()]; int decryptedLen = 0; int i; while ((i = cis.read(decryptedData, decryptedLen, decryptedData.length - decryptedLen)) > -1) { decryptedLen += i; } return Arrays.copyOf(decryptedData, decryptedLen); } catch (IOException e) { throw new CryptoException(e); } }
AESCipher implements Cipher { @Override public byte[] decrypt(byte[] encryptData) { Properties properties = new Properties(); try (ByteArrayInputStream inputStream = new ByteArrayInputStream(encryptData); CryptoInputStream cis = new CryptoInputStream(KEY_ALGORITHM_TRANSFORM, properties, inputStream, key, iv)) { byte[] decryptedData = new byte[cis.available()]; int decryptedLen = 0; int i; while ((i = cis.read(decryptedData, decryptedLen, decryptedData.length - decryptedLen)) > -1) { decryptedLen += i; } return Arrays.copyOf(decryptedData, decryptedLen); } catch (IOException e) { throw new CryptoException(e); } } }
AESCipher implements Cipher { @Override public byte[] decrypt(byte[] encryptData) { Properties properties = new Properties(); try (ByteArrayInputStream inputStream = new ByteArrayInputStream(encryptData); CryptoInputStream cis = new CryptoInputStream(KEY_ALGORITHM_TRANSFORM, properties, inputStream, key, iv)) { byte[] decryptedData = new byte[cis.available()]; int decryptedLen = 0; int i; while ((i = cis.read(decryptedData, decryptedLen, decryptedData.length - decryptedLen)) > -1) { decryptedLen += i; } return Arrays.copyOf(decryptedData, decryptedLen); } catch (IOException e) { throw new CryptoException(e); } } AESCipher(String key, String iv);  AESCipher(byte[] key, byte[] iv); }
AESCipher implements Cipher { @Override public byte[] decrypt(byte[] encryptData) { Properties properties = new Properties(); try (ByteArrayInputStream inputStream = new ByteArrayInputStream(encryptData); CryptoInputStream cis = new CryptoInputStream(KEY_ALGORITHM_TRANSFORM, properties, inputStream, key, iv)) { byte[] decryptedData = new byte[cis.available()]; int decryptedLen = 0; int i; while ((i = cis.read(decryptedData, decryptedLen, decryptedData.length - decryptedLen)) > -1) { decryptedLen += i; } return Arrays.copyOf(decryptedData, decryptedLen); } catch (IOException e) { throw new CryptoException(e); } } AESCipher(String key, String iv);  AESCipher(byte[] key, byte[] iv); @Override byte[] decrypt(byte[] encryptData); @Override byte[] encrypt(byte[] originData); @Override String toString(); static byte[] toArray(String str); }
AESCipher implements Cipher { @Override public byte[] decrypt(byte[] encryptData) { Properties properties = new Properties(); try (ByteArrayInputStream inputStream = new ByteArrayInputStream(encryptData); CryptoInputStream cis = new CryptoInputStream(KEY_ALGORITHM_TRANSFORM, properties, inputStream, key, iv)) { byte[] decryptedData = new byte[cis.available()]; int decryptedLen = 0; int i; while ((i = cis.read(decryptedData, decryptedLen, decryptedData.length - decryptedLen)) > -1) { decryptedLen += i; } return Arrays.copyOf(decryptedData, decryptedLen); } catch (IOException e) { throw new CryptoException(e); } } AESCipher(String key, String iv);  AESCipher(byte[] key, byte[] iv); @Override byte[] decrypt(byte[] encryptData); @Override byte[] encrypt(byte[] originData); @Override String toString(); static byte[] toArray(String str); static final String KEY_ALGORITHM; static final String KEY_ALGORITHM_TRANSFORM; final byte[] keyB; final byte[] ivB; }