1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
package issrg.SAWS; |
47 |
|
|
48 |
|
import java.io.*; |
49 |
|
import java.util.*; |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
import org.w3c.dom.*; |
60 |
|
import org.xml.sax.*; |
61 |
|
import javax.xml.parsers.*; |
62 |
|
import org.apache.soap.util.xml.*; |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
import java.security.*; |
67 |
|
import javax.crypto.*; |
68 |
|
import java.security.AlgorithmParameters; |
69 |
|
import java.security.interfaces.*; |
70 |
|
|
71 |
|
|
|
|
| 68.4% |
Uncovered Elements: 25 (79) |
Complexity: 9 |
Complexity Density: 0.37 |
|
72 |
|
public class utility |
73 |
|
{ |
74 |
|
|
75 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
76 |
0
|
public static byte intToByte(int value) {... |
77 |
0
|
byte b = (byte) (value & 0xFF); |
78 |
0
|
return b; |
79 |
|
} |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
81 |
0
|
public static int byteToInt(byte b) {... |
82 |
0
|
int value = 0; |
83 |
0
|
value = (b & 0x000000FF); |
84 |
0
|
return value; |
85 |
|
} |
86 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
87 |
242
|
public static byte[] longToByteArray(long value) {... |
88 |
242
|
byte[] b = new byte[8]; |
89 |
2178
|
for (int i = 0; i < 8; i++) { |
90 |
1936
|
int offset = (b.length - 1 - i) * 8; |
91 |
1936
|
b[i] = (byte) ((value >>> offset) & 0xFF); |
92 |
|
} |
93 |
242
|
return b; |
94 |
|
} |
95 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
96 |
540
|
public static long byteArrayToLong(byte[] b) {... |
97 |
|
|
98 |
540
|
long value = 0; |
99 |
4860
|
for (int i = 0; i < 8; i++) { |
100 |
4320
|
int shift = (7 - i) * 8; |
101 |
4320
|
value += (long)( (long)(b[i] & 0x00000000000000FF) << shift ); |
102 |
|
|
103 |
|
|
104 |
|
} |
105 |
540
|
return value; |
106 |
|
|
107 |
|
} |
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
@param |
113 |
|
@param |
114 |
|
@return |
115 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
116 |
0
|
public static long byteArrayToLong(byte[] b, int offset) {... |
117 |
0
|
long value = 0; |
118 |
0
|
for (int i = 0; i < 8; i++) { |
119 |
0
|
int shift = (8 - 1 - i) * 8; |
120 |
0
|
value += ( (long)(b[i + offset] & 0x00000000000000FF) << shift ); |
121 |
|
} |
122 |
0
|
return value; |
123 |
|
} |
124 |
|
|
125 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
126 |
675
|
public static byte[] intToByteArray(int value) {... |
127 |
675
|
byte[] b = new byte[4]; |
128 |
3375
|
for (int i = 0; i < 4; i++) { |
129 |
2700
|
int offset = (b.length - 1 - i) * 8; |
130 |
2700
|
b[i] = (byte) ((value >>> offset) & 0xFF); |
131 |
|
} |
132 |
675
|
return b; |
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
@param |
140 |
|
@return |
141 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
142 |
1788
|
public static int byteArrayToInt(byte[] b) {... |
143 |
1788
|
return byteArrayToInt(b, 0); |
144 |
|
} |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
@param |
150 |
|
@param |
151 |
|
@return |
152 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
153 |
1788
|
public static int byteArrayToInt(byte[] b, int offset) {... |
154 |
1788
|
int value = 0; |
155 |
8940
|
for (int i = 0; i < 4; i++) { |
156 |
7152
|
int shift = (4 - 1 - i) * 8; |
157 |
7152
|
value += (b[i + offset] & 0x000000FF) << shift; |
158 |
|
} |
159 |
1788
|
return value; |
160 |
|
} |
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
166 |
0
|
public static String byte2hex(byte b) {... |
167 |
0
|
StringBuffer buf = new StringBuffer(); |
168 |
0
|
char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', |
169 |
|
'9', 'A', 'B', 'C', 'D', 'E', 'F' }; |
170 |
0
|
int high = ((b & 0xf0) >> 4); |
171 |
0
|
int low = (b & 0x0f); |
172 |
0
|
buf.append(hexChars[high]); |
173 |
0
|
buf.append(hexChars[low]); |
174 |
0
|
return(buf.toString()); |
175 |
|
} |
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
180 |
120
|
public static void byte2hex(byte b, StringBuffer buf) {... |
181 |
120
|
char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', |
182 |
|
'9', 'A', 'B', 'C', 'D', 'E', 'F' }; |
183 |
120
|
int high = ((b & 0xf0) >> 4); |
184 |
120
|
int low = (b & 0x0f); |
185 |
120
|
buf.append(hexChars[high]); |
186 |
120
|
buf.append(hexChars[low]); |
187 |
|
} |
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
|
|
| 86.7% |
Uncovered Elements: 2 (15) |
Complexity: 4 |
Complexity Density: 0.44 |
|
192 |
6
|
public static String toHexString(byte[] block) {... |
193 |
|
|
194 |
0
|
if (block == null) return null; |
195 |
6
|
StringBuffer buf = new StringBuffer(); |
196 |
|
|
197 |
6
|
int len = block.length; |
198 |
|
|
199 |
126
|
for (int i = 0; i < len; i++) { |
200 |
120
|
byte2hex(block[i], buf); |
201 |
120
|
if (i < len-1) { |
202 |
114
|
buf.append(":"); |
203 |
|
} |
204 |
|
} |
205 |
6
|
return buf.toString(); |
206 |
|
} |
207 |
|
|
208 |
|
} |