以下の手法を使用してデータファイルを暗号化するクライアント側にJava 8をインストールしました
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, key);
outputStream = new CipherOutputStream(new FileOutputStream(encryptedFile), cipher);
そして今、私は以下のコードに従ってJava 7がインストールされているサーバー側で復号化しています。
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, publicKey);
inputStream = new CipherInputStream(new FileInputStream(encryptedFile), cipher);
outputStream = new FileOutputStream(decryptedFileName);
そうすることで、以下のエラーが表示されます
Caused by: java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded
at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:115) [jce.jar:1.7.0_71]
at javax.crypto.CipherInputStream.read(CipherInputStream.java:233) [jce.jar:1.7.0_71]
at javax.crypto.CipherInputStream.read(CipherInputStream.java:209) [jce.jar:1.7.0_71]
両側に同じ Java バージョン (1.7) がインストールされている場合、同じコードが正常に動作します。どちらの側でもJavaバージョンを変更せずにこれを修正するにはどうすればよいですか