Шифрует хорошо, на дешифровке ошибка. а в валидаторе 4 пунка не проходит. немогу нагуглить что это за ошибка. может кто сталкивался?
Input length must be multiple of 16 when decrypting with padded cipher
package com.javarush.task.task18.task1826;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
import java.io.*;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
/*
Шифровка
*/
public class Solution {
public static void main(String[] args) throws IOException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
FileInputStream inputStream = new FileInputStream(args[1]);
FileOutputStream outputStream = new FileOutputStream(args[2]);
SecretKeySpec key = new SecretKeySpec("ABCd1234abcD1234".getBytes(), "AES");
if (args[0].equals("-e")) {
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] bytes = new byte[1000];
byte[] finale;
int count = 0;
while (inputStream.available() > 0) {
count = inputStream.read(bytes);
}
finale = cipher.doFinal(bytes);
outputStream.write(finale, 0 , count);
} else if (args[0].equals("-d")) {
Cipher decriptCipher = Cipher.getInstance("AES");
decriptCipher.init(Cipher.DECRYPT_MODE, key);
byte[] bytes = new byte[1000];
byte[] finale;
int count = 0;
while (inputStream.available() > 0) {
count = inputStream.read(bytes);
}
finale = decriptCipher.doFinal(bytes);
outputStream.write(finale, 0, bytes.length);
}
reader.close();
inputStream.close();
outputStream.close();
}
}