X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.util%2Fsrc%2Forg%2Fargeo%2Futil%2FDigestUtils.java;h=38b4e7032a5cf35328b010771fe02a154f0c0d49;hb=212a43ed44ffc186b69e838d65a1421fd5e1f3a5;hp=e1a19160bd5a04afe23f834b6556e41bf53d91dd;hpb=e5a22cdc7d0f4918f2740c626e1ab6384bd5ee44;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.util/src/org/argeo/util/DigestUtils.java b/org.argeo.util/src/org/argeo/util/DigestUtils.java index e1a19160b..38b4e7032 100644 --- a/org.argeo.util/src/org/argeo/util/DigestUtils.java +++ b/org.argeo.util/src/org/argeo/util/DigestUtils.java @@ -1,7 +1,5 @@ package org.argeo.util; -import static org.argeo.util.BytesUtils.toHexString; - import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -188,10 +186,17 @@ public class DigestUtils { } } - /** @deprecated Use {@link BytesUtils#toHexString(byte[])} instead */ - @Deprecated - public static String encodeHexString(byte[] bytes) { - return BytesUtils.toHexString(bytes); + final private static char[] hexArray = "0123456789abcdef".toCharArray(); + + /** Converts a byte array to an hex String. */ + public static String toHexString(byte[] bytes) { + char[] hexChars = new char[bytes.length * 2]; + for (int j = 0; j < bytes.length; j++) { + int v = bytes[j] & 0xFF; + hexChars[j * 2] = hexArray[v >>> 4]; + hexChars[j * 2 + 1] = hexArray[v & 0x0F]; + } + return new String(hexChars); } }