From 3f315df6c8e0af0180215e19733a06f7efa1fae1 Mon Sep 17 00:00:00 2001 From: AsamK Date: Mon, 23 Mar 2020 11:31:55 +0100 Subject: [PATCH] Add toString method to Hex utils --- .../asamk/signal/commands/ListIdentitiesCommand.java | 2 +- src/main/java/org/asamk/signal/util/Hex.java | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/asamk/signal/commands/ListIdentitiesCommand.java b/src/main/java/org/asamk/signal/commands/ListIdentitiesCommand.java index dd3e5e46..a7cf8705 100644 --- a/src/main/java/org/asamk/signal/commands/ListIdentitiesCommand.java +++ b/src/main/java/org/asamk/signal/commands/ListIdentitiesCommand.java @@ -18,7 +18,7 @@ public class ListIdentitiesCommand implements LocalCommand { private static void printIdentityFingerprint(Manager m, String theirUsername, JsonIdentityKeyStore.Identity theirId) { String digits = Util.formatSafetyNumber(m.computeSafetyNumber(theirUsername, theirId.getIdentityKey())); System.out.println(String.format("%s: %s Added: %s Fingerprint: %s Safety Number: %s", theirUsername, - theirId.getTrustLevel(), theirId.getDateAdded(), Hex.toStringCondensed(theirId.getFingerprint()), digits)); + theirId.getTrustLevel(), theirId.getDateAdded(), Hex.toString(theirId.getFingerprint()), digits)); } @Override diff --git a/src/main/java/org/asamk/signal/util/Hex.java b/src/main/java/org/asamk/signal/util/Hex.java index 95b2d26f..8c6c62a2 100644 --- a/src/main/java/org/asamk/signal/util/Hex.java +++ b/src/main/java/org/asamk/signal/util/Hex.java @@ -9,6 +9,15 @@ public class Hex { 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 (final byte aByte : bytes) { @@ -20,7 +29,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) {