]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/util/Hex.java
Reformat project
[signal-cli] / src / main / java / org / asamk / signal / util / Hex.java
index 623c5cf84be3f816a6151322dc7eea45324a9f30..46609ceb8fec54b16dfa527ef7703dff852f98fc 100644 (file)
@@ -2,14 +2,24 @@ package org.asamk.signal.util;
 
 public class Hex {
 
-    private final static char[] HEX_DIGITS = {
-            '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
-    };
+    private final static char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+    private Hex() {
+    }
+
+    public static String toString(byte[] bytes) {
+        StringBuffer buf = new StringBuffer();
+        for (final byte aByte : bytes) {
+            appendHexChar(buf, aByte);
+            buf.append(" ");
+        }
+        return buf.toString();
+    }
 
     public static String toStringCondensed(byte[] bytes) {
         StringBuffer buf = new StringBuffer();
-        for (int i = 0; i < bytes.length; i++) {
-            appendHexChar(buf, bytes[i]);
+        for (final byte aByte : bytes) {
+            appendHexChar(buf, aByte);
         }
         return buf.toString();
     }
@@ -17,7 +27,6 @@ public class Hex {
     private static void appendHexChar(StringBuffer buf, int b) {
         buf.append(HEX_DIGITS[(b >> 4) & 0xf]);
         buf.append(HEX_DIGITS[b & 0xf]);
-        buf.append(" ");
     }
 
     public static byte[] toByteArray(String s) {