Я делаю расшифровку шифрования файла в Android, для этого я использую следующий код
private void encryptFile()
{
try
{
File f = new File(Environment.getExternalStorageDirectory() + "/images.jpg");
FileInputStream in = new FileInputStream(f);
byte[] buffer = new byte[100];
int num = in.read(buffer, 0, 100);
Encryption mEncryption = new Encryption("test");
File tempFile = new File(Environment.getExternalStorageDirectory() + "/temp.jpg");
FileOutputStream os = new FileOutputStream(tempFile);
os.write(mEncryption.encrypt(buffer), 0, 100);
while(in.read(buffer) != -1)
{
os.write(buffer);
}
in.close();
os.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
private void decryptFile()
{
try
{
File f = new File(Environment.getExternalStorageDirectory() + "/temp.jpg");
FileInputStream in = new FileInputStream(f);
byte[] buffer = new byte[100];
in.read(buffer, 0, 100);
Encryption mEncryption = new Encryption("test");
File tempFile = new File(Environment.getExternalStorageDirectory() + "/images.jpg");
FileOutputStream os = new FileOutputStream(tempFile);
os.write(mEncryption.decrypt(buffer), 0, 100);
while(in.read(buffer) != -1)
{
os.write(buffer);
}
in.close();
os.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
, но когда я дешифрую файл, он дает мне IllegalBlockSizeException: last block incomplete in decryption
любую идею, почему это происходит?
Редактировать: Я использую это Класс шифрования