Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #990

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

test #990

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading