--- a/jdk/test/com/sun/crypto/provider/Cipher/DES/TestUtility.java Tue Jan 06 13:58:24 2015 +0000
+++ b/jdk/test/com/sun/crypto/provider/Cipher/DES/TestUtility.java Wed Jan 07 03:59:06 2015 +0000
@@ -27,39 +27,52 @@
public class TestUtility {
- private static final String digits = "0123456789abcdef";
+ private static final String DIGITS = "0123456789abcdef";
- public TestUtility() {
+ private TestUtility() {
}
public static String hexDump(byte[] bytes) {
- StringBuffer buf = new StringBuffer (bytes.length * 2);
- int i;
+ StringBuilder buf = new StringBuilder(bytes.length * 2);
+ int i;
- buf.append (" "); // four spaces
+ buf.append(" "); // four spaces
for (i = 0; i < bytes.length; i++) {
- buf.append (digits.charAt ((bytes[i] >> 4) & 0x0f));
- buf.append (digits.charAt (bytes[i] & 0x0f));
- if (((i + 1) % 32) == 0) {
- if ((i + 1) != bytes.length)
- buf.append ("\n "); // line after four words
- } else if (((i + 1) % 4) == 0)
- buf.append (' '); // space between words
+ buf.append(DIGITS.charAt(bytes[i] >> 4 & 0x0f));
+ buf.append(DIGITS.charAt(bytes[i] & 0x0f));
+ if ((i + 1) % 32 == 0) {
+ if (i + 1 != bytes.length) {
+ buf.append("\n "); // line after four words
+ }
+ } else if ((i + 1) % 4 == 0) {
+ buf.append(' '); // space between words
+ }
}
- return buf.toString ();
+ return buf.toString();
}
+ public static String hexDump(byte[] bytes, int index) {
+ StringBuilder buf = new StringBuilder(bytes.length * 2);
+ int i;
+
+ buf.append(" "); // four spaces
+ buf.append(DIGITS.charAt(bytes[index] >> 4 & 0x0f));
+ buf.append(DIGITS.charAt(bytes[index] & 0x0f));
+ return buf.toString();
+ }
public static boolean equalsBlock(byte[] b1, byte[] b2) {
- if (b1.length != b2.length)
+ if (b1.length != b2.length) {
return false;
+ }
- for (int i=0; i<b1.length; i++) {
- if (b1[i] != b2[i])
+ for (int i = 0; i < b1.length; i++) {
+ if (b1[i] != b2[i]) {
return false;
+ }
}
return true;
@@ -67,9 +80,10 @@
public static boolean equalsBlock(byte[] b1, byte[] b2, int len) {
- for (int i=0; i<len; i++) {
- if (b1[i] != b2[i])
+ for (int i = 0; i < len; i++) {
+ if (b1[i] != b2[i]) {
return false;
+ }
}
return true;