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 6db8bd17a0
commit 3718d15004
1 changed files with 1 additions and 1 deletions

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)