diff --git a/test/com/sun/crypto/provider/Cipher/DES/TestUtility.java b/test/com/sun/crypto/provider/Cipher/DES/TestUtility.java index 61efd621bdb87ffb082ff85b576e49636e318c5e..ffa0a5bfcb3dfbe279df6e29ba98465c7876ec8b 100644 --- a/test/com/sun/crypto/provider/Cipher/DES/TestUtility.java +++ b/test/com/sun/crypto/provider/Cipher/DES/TestUtility.java @@ -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 0) { + even = !even; + } + } + if (keyByte < 0) { + even = !even; + } + + return even; + } +}