все работает (проверено на фотографии), но валидатор не принимает ни одного пункта((( Может, знает кто в чем дело?
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.DESKeySpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
/*
Шифровка
*/
/*-e fileName fileOutputName
-d fileName fileOutputName*/
public class Solution {
private static final byte[] keyBytes = new byte[]{-14, 99, 104, -30, -1, 70, -40, 71};
private static final String transformation = "DES";
private static final int CHUNKSIZE = 1000;
public static void main(String[] args) throws IOException,
NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException,
IllegalBlockSizeException, BadPaddingException {
if (args.length < 3) return;
byte[] plain = new byte[CHUNKSIZE];
byte[] secret;
Cipher desCipher = Cipher.getInstance(transformation);
SecretKeySpec key = new SecretKeySpec(keyBytes, transformation);
FileInputStream input = new FileInputStream(args[1]);
FileOutputStream output = new FileOutputStream(args[2]);
int count;
switch (args[0]) {
case "-e":
desCipher.init(Cipher.ENCRYPT_MODE, key);
while (input.available() > 0) {
count = input.read(plain);
if (count == CHUNKSIZE) secret = desCipher.update(plain);
else secret = desCipher.doFinal(plain, 0, count);
output.write(secret);
}
break;
case "-d":
desCipher.init(Cipher.DECRYPT_MODE, key);
while (input.available() > 0) {
count = input.read(plain);
if (count == CHUNKSIZE) secret = desCipher.update(plain);
else secret = desCipher.doFinal(plain,0, count );
output.write(secret);
}
break;
default: ;
}
input.close();
output.close();
}
}