Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ibodrov committed Oct 4, 2024
1 parent e27e123 commit b779824
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Base64;

public final class SecretUtils {

Expand Down Expand Up @@ -72,7 +73,9 @@ public static byte[] decrypt(byte[] input, byte[] password, byte[] salt, HashAlg
} catch (IOException e) {
Throwable t = e.getCause() == null ? e : e.getCause();
if (t instanceof BadPaddingException) {
throw new SecurityException("Error decrypting a secret: " + t.getMessage() + ". Invalid input data and/or a password.");
throw new SecurityException("Error decrypting a secret: " + t.getMessage() + ". Invalid input data and/or a password. " +
"Password: " + Base64.getEncoder().encodeToString(password) + ", salt: " + Base64.getEncoder().encodeToString(salt) +
"algorithm: " + hashAlgorithm.getName());
}
throw new SecurityException("Error decrypting a secret: " + e.getMessage(), t);
}
Expand All @@ -87,7 +90,9 @@ public static InputStream decrypt(InputStream input, byte[] password, byte[] sal
Cipher c = init(password, salt, Cipher.DECRYPT_MODE, hashAlgorithm);
return new CipherInputStream(input, c);
} catch (BadPaddingException e) {
throw new SecurityException("Error decrypting a secret: " + e.getMessage() + ". Invalid input data and/or a password.");
throw new SecurityException("Error decrypting a secret: " + e.getMessage() + ". Invalid input data and/or a password. " +
"Password: " + Base64.getEncoder().encodeToString(password) + ", salt: " + Base64.getEncoder().encodeToString(salt) +
"algorithm: " + hashAlgorithm.getName());
} catch (GeneralSecurityException e) {
throw new SecurityException("Error decrypting a secret: " + e.getMessage());
}
Expand Down

0 comments on commit b779824

Please sign in to comment.