mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Add toString method to Hex utils
This commit is contained in:
parent
bb06ae9d9a
commit
3f315df6c8
2 changed files with 10 additions and 2 deletions
|
@ -18,7 +18,7 @@ public class ListIdentitiesCommand implements LocalCommand {
|
||||||
private static void printIdentityFingerprint(Manager m, String theirUsername, JsonIdentityKeyStore.Identity theirId) {
|
private static void printIdentityFingerprint(Manager m, String theirUsername, JsonIdentityKeyStore.Identity theirId) {
|
||||||
String digits = Util.formatSafetyNumber(m.computeSafetyNumber(theirUsername, theirId.getIdentityKey()));
|
String digits = Util.formatSafetyNumber(m.computeSafetyNumber(theirUsername, theirId.getIdentityKey()));
|
||||||
System.out.println(String.format("%s: %s Added: %s Fingerprint: %s Safety Number: %s", theirUsername,
|
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
|
@Override
|
||||||
|
|
|
@ -9,6 +9,15 @@ public class Hex {
|
||||||
private 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) {
|
public static String toStringCondensed(byte[] bytes) {
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
for (final byte aByte : bytes) {
|
for (final byte aByte : bytes) {
|
||||||
|
@ -20,7 +29,6 @@ public class Hex {
|
||||||
private static void appendHexChar(StringBuffer buf, int b) {
|
private static void appendHexChar(StringBuffer buf, int b) {
|
||||||
buf.append(HEX_DIGITS[(b >> 4) & 0xf]);
|
buf.append(HEX_DIGITS[(b >> 4) & 0xf]);
|
||||||
buf.append(HEX_DIGITS[b & 0xf]);
|
buf.append(HEX_DIGITS[b & 0xf]);
|
||||||
buf.append(" ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] toByteArray(String s) {
|
public static byte[] toByteArray(String s) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue