CryptEngine { public byte[] decrypt(byte[] data, byte[] key) { try { Cipher rsa = Cipher.getInstance("Blowfish/ECB/NoPadding", BouncyCastleProvider.PROVIDER_NAME); SecretKeySpec keySpec = new SecretKeySpec(key, "Blowfish"); rsa.init(Cipher.DECRYPT_MODE, keySpec); for (int i = 0; i < data.length; i += BLOCK_SIZE) { rsa.doFinal(data, i, BLOCK_SIZE, data, i); if (i > 0) { for (int j = i; j < i + BLOCK_SIZE; j++) { data[j] ^= data[j - BLOCK_SIZE]; } } } } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | NoSuchProviderException | BadPaddingException | IllegalBlockSizeException | ShortBufferException e) { e.printStackTrace(); } return data; } private  CryptEngine(); static CryptEngine getInstance(); byte[] decrypt(byte[] data, byte[] key); byte[] encrypt(byte[] data, byte key[], int padding); static final int ZERO_TRAILING_MODE; static final int RANDOM_BYTES_MODE; }
@Test public void decryptTest() { byte[] result = CryptEngine.getInstance().decrypt(in, key); System.out.println(bytesToHexString(result)); System.out.println(new String(result)); assertArrayEquals(result, out); }