[Minor] code cleanup in AesCryptoHelper

This commit is contained in:
Robert von Burg 2023-04-06 10:24:20 +02:00
parent abf02c3c3d
commit 1c60977bc4
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
1 changed files with 4 additions and 7 deletions

View File

@ -80,7 +80,8 @@ public class AesCryptoHelper {
// read the initialization vector from the normal input stream
byte[] initVector = new byte[16];
inputStream.read(initVector);
if (inputStream.read(initVector) == -1)
throw new IllegalStateException("Failed to read init vector!");
// init cipher
Cipher cipher = Cipher.getInstance(CIPHER);
@ -196,7 +197,6 @@ public class AesCryptoHelper {
}
logger.info("Decrypted file " + encryptedFileS + " to " + decryptedFileS);
}
public static void decrypt(char[] password, byte[] salt, InputStream fis, OutputStream fos) {
@ -219,7 +219,8 @@ public class AesCryptoHelper {
// read the initialization vector
byte[] initVector = new byte[16];
fis.read(initVector);
if (fis.read(initVector) == -1)
throw new IllegalStateException("Failed to read init vector!");
// init cipher
Cipher cipher = Cipher.getInstance(CIPHER);
@ -248,10 +249,6 @@ public class AesCryptoHelper {
return encrypt(password, salt, clearText.getBytes());
}
public static byte[] encrypt(SecretKey secret, byte[] salt, String clearText) {
return encrypt(secret, clearText.getBytes());
}
public static byte[] encrypt(char[] password, byte[] salt, byte[] clearTextBytes) {
try {