mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8252055: Use java.util.HexFormat in java.security
Reviewed-by: xuelei
This commit is contained in:
parent
1dae45d745
commit
68f2acbf4c
15 changed files with 71 additions and 241 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -27,6 +27,7 @@ package sun.security.util;
|
|||
|
||||
import java.io.PrintStream;
|
||||
import java.math.BigInteger;
|
||||
import java.util.HexFormat;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.Locale;
|
||||
|
@ -318,22 +319,11 @@ public class Debug {
|
|||
return null;
|
||||
}
|
||||
|
||||
private static final char[] hexDigits = "0123456789abcdef".toCharArray();
|
||||
|
||||
public static String toString(byte[] b) {
|
||||
if (b == null) {
|
||||
return "(null)";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(b.length * 3);
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
int k = b[i] & 0xff;
|
||||
if (i != 0) {
|
||||
sb.append(':');
|
||||
}
|
||||
sb.append(hexDigits[k >>> 4]);
|
||||
sb.append(hexDigits[k & 0xf]);
|
||||
}
|
||||
return sb.toString();
|
||||
return HexFormat.ofDelimiter(":").formatHex(b);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue