Update SHACommonUtils.java

Replace StringBuffer with StringBuilder and add initial  capacity.
StringBuilder is faster because it is not synchronized.
This commit is contained in:
Tobias Weimer
2020-07-25 23:24:14 +02:00
committed by GitHub
parent c3802b3d59
commit aab528a334

View File

@@ -3,7 +3,7 @@ package com.baeldung.hashing;
class SHACommonUtils {
public static String bytesToHex(byte[] hash) {
StringBuffer hexString = new StringBuffer();
StringBuilder hexString = new StringBuilder(2 * hash.length);
for (byte h : hash) {
String hex = Integer.toHexString(0xff & h);
if (hex.length() == 1)