Почему ему не нравится решение на основе 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;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws NoSuchPaddingException, NoSuchAlgorithmException, IOException, BadPaddingException, IllegalBlockSizeException, InvalidKeyException {
Cipher cipher = Cipher.getInstance("AES");
byte[] keyBytes = new byte[]{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
String algorithm = "AES";
SecretKeySpec key = new SecretKeySpec(keyBytes, algorithm);
FileInputStream inputStream = new FileInputStream(args[1]);
FileOutputStream outputStream = new FileOutputStream(args[2]);
if(args[0].equals("-e"))
{
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] buffer = new byte[inputStream.available()];
while (inputStream.available() > 0)
{
inputStream.read(buffer);
}
byte[] cipherText = cipher.doFinal(buffer);
outputStream.write(cipherText);
inputStream.close();
outputStream.close();
}
if(args[0].equals("-d"))
{
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] buffer = new byte[inputStream.available()];
while (inputStream.available() > 0)
{
inputStream.read(buffer);
}
byte[] cipherText = cipher.doFinal(buffer);
outputStream.write(cipherText);
inputStream.close();
outputStream.close();
}
}
}