The crypt/Util.hexToBytes method, with a line of debugging code at the end:
public static byte[] hexToBytes(String s) throws NumberFormatException {
if ((s.length() % 2) != 0) {
s="0"+s;
}
byte[] out = new byte[s.length() / 2];
byte b;
for (int i=0; i < s.length(); i++) {
char c = Character.toLowerCase(s.charAt(i));
if (!((c >= 'a' && c <= 'f') || (c >= '0' && c <='9')))
throw new NumberFormatException();
b = (byte) (c >= 'a' && c <='f' ? c - 'a' + 10 : c - '0');
if (i%2 == 0) {
out[i/2] = (byte) (b << 4);
} else {
out[(i-1)/2] = (byte) (out[(i-1)/2] | b);
}
}
for (int i = 0 ; i < s.length() / 2 ; i++) System.out.print(out[i]+" ");
return out;
}
The output to the byte array deviates halfway through:
(IBM) 7 -31 -69 -69 -92 -30 -34 -29 96 -31 -75 84 -46 -101 85 -36 -117 122
-15 -94 -57 3 1 123 127 -31 -56 59 -109 88 -2 -25 110 -28 -125 -48 -64 -29
43 114 -16 59 103 -5 -24 54 62 -104 105 -111 125 53 76 92 49 -92 -124 -38
47 -50 -24 95 82 23 51 8 89 47 -18 -73 -36 -30 -12 1 -66 -90 57 -69 -126
48 -56 -50 97 -121 -51 56 -124 -19 -67 -111 48 91 75 -73 84 -22 -123 -82
15 81 81 120 -34 78 -112 49 105 72 -33 -84 -61 -36 117 -37 -7 116 16 -106
110 126 35 -70 6 -23 -77 61 78 -66 -104 6 -111 38 85 -34 -73 -124 96 41
114 25 62 -93 36 31 -118 -45 71 38 -97 107 -47 109 94 -88 32 -31 7 -79
-111 -60 -79 -20 -115 102 -49 -89 -38 60
(GCJ) 7 -31 -69 -69 -92 -30 -34 -29 96 -31 -75 84 -46 -101 85 -36 -117 122
-15 -94 -57 3 1 123 127 -31 -56 59 -109 88 -2 -25 110 -28 -125 -48 -64 -29
43 114 -16 59 103 -5 -24 54 62 -104 105 -111 125 53 76 92 49 -92 -124 -38
47 -50 -24 95 82 23 51 8 89 47 -18 -73 -36 -30 -12 1 -66 -90 57 -69 -126
48 -56 -50 97 -121 -51 56 -124 -19 -67 -111 48 91 75 -73 84 -22 -123 -82
15 81 81 120 -34 78 -112 49 105 72 -33 -84 -61 -36 117 -37 -7 116 16 -106
110 126 35 -70 6 -23 -77 61 78 -66 6 67 0 28 119 -77 61 -70 80 74 77 -105
55 0 -70 -68 120 -101 72 -105 65 58 -77 61 -25 -85 109 -29 5 -86 1 88 94
-91 32 38 21 -122 -117 -71
where the value is munged to "6" instead of "-104".
--
Mark Roberts
mjr at statesmean.com
_______________________________________________
Devl mailing list
Devl at freenetproject.org
http://www.uprizer.com/mailman/listinfo/devl