Skip to content
Closed
Show file tree
Hide file tree
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 @@ -423,11 +423,8 @@ private static String sha256Hex(byte[] bytes) {
try {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] raw = digest.digest(bytes);
StringBuilder hex = new StringBuilder(raw.length * 2);
for (byte b : raw) {
hex.append(String.format("%02x", b));
}
return hex.toString();
// Bolt: Using HexFormat for faster byte-to-hex conversion instead of String.format inside a loop.
return java.util.HexFormat.of().formatHex(raw);
} catch (GeneralSecurityException ex) {
throw new IllegalStateException("SHA-256 digest unavailable", ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,8 @@ private String contentHash(MultipartFile file) {
}

byte[] raw = digest.digest();
StringBuilder hex = new StringBuilder(raw.length * 2);
for (byte b : raw) {
hex.append(String.format("%02x", b));
}

return hex.toString();
// Bolt: Using HexFormat for faster byte-to-hex conversion instead of String.format inside a loop.
return java.util.HexFormat.of().formatHex(raw);
} catch (NoSuchAlgorithmException ex) {
throw new IllegalStateException("SHA-256 digest unavailable", ex);
} catch (IOException ex) {
Expand Down
Loading