mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-13 12:02:20 +00:00
Replace MD5 digest with SHA256 while logging payload in Mock class called from tests (#8319)
This commit is contained in:
1 parent
7f7f8658a5
commit
4a262f5e71
3 files changed
+48
-2
No files matched your search
@@ -1927,4 +1927,29 @@ public class Util {
|
||||
private static PathRemover newPathRemover(@NonNull PathRemover.PathChecker pathChecker) {
|
||||
return PathRemover.newFilteredRobustRemover(pathChecker, DELETION_RETRIES, GC_AFTER_FAILED_DELETE, WAIT_BETWEEN_DELETION_RETRIES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns SHA-256 Digest of input bytes
|
||||
*/
|
||||
@Restricted(NoExternalUse.class)
|
||||
public static byte[] getSHA256DigestOf(@NonNull byte[] input) {
|
||||
try {
|
||||
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
|
||||
messageDigest.update(input);
|
||||
return messageDigest.digest();
|
||||
} catch (NoSuchAlgorithmException noSuchAlgorithmException) {
|
||||
throw new IllegalStateException("SHA-256 could not be instantiated, but is required to" +
|
||||
" be implemented by the language specification", noSuchAlgorithmException);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Hex string of SHA-256 Digest of passed input
|
||||
*/
|
||||
@Restricted(NoExternalUse.class)
|
||||
public static String getHexOfSHA256DigestOf(byte[] input) throws IOException {
|
||||
//get hex string of sha 256 of payload
|
||||
byte[] payloadDigest = Util.getSHA256DigestOf(input);
|
||||
return (payloadDigest != null) ? Util.toHexString(payloadDigest) : null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user