· 5 years ago · Jun 29, 2020, 11:28 AM
1import java.io.UnsupportedEncodingException;
2import java.lang.reflect.Array;
3import java.nio.charset.StandardCharsets;
4import java.security.NoSuchAlgorithmException;
5import java.util.Arrays;
6
7import javax.crypto.KeyGenerator;
8import javax.crypto.SecretKey;
9
10public class aesContoh{
11
12 static char[] input; //Penampung input
13 static int[][] output; //Penampung output
14 static char[] secret; //Penampung secret key
15 static int[][] state; //Penampung status
16 static int[][] rahasia; //Penampung konversi secret key ke int
17 static int[][] s_box; //Penampung sbox
18 static int[][] invs_box; //Penampung inverse s-box
19 static int nb, nr,nk; //Penampung nb dan nr
20 static byte[][] Kunci;
21 //Isi S-Box
22 public static int[] sbox = {0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
23 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
24 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
25 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
26 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
27 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
28 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
29 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
30 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
31 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
32 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
33 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
34 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
35 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
36 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
37 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16};
38
39//Isi Inverse S-Box
40public static int[] invsbox = {0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,
41 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,
42 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
430x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25,
440x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92,
450x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
460x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06,
47 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b,
48 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
49 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e,
50 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b,
51 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
52 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f,
53 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef,
54 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
550x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d};
56
57
58//Isi RCon untuk Key Expansion
59 public static final int[] rcon = {0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a,
60 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39,
61 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a,
62 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8,
63 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef,
64 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc,
65 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b,
66 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3,
67 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94,
68 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20,
69 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35,
70 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f,
71 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04,
72 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63,
73 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd,
74 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb};
75
76
77/*Prosedur enkripsi*/
78
79 //Enkripsi Text
80 public static byte[] Encrypt(byte[] in, byte[] secret){
81 nb = 4;
82 nk = secret.length/4;
83 nr = nk+6;
84 int length = 0;
85 byte[] padding = new byte[1];
86 int i;
87 length = 16 - in.length % 16;
88
89
90 padding = new byte[length];
91 padding[0] = (byte) 0x80;
92 for(i=1 ; i < length;i++){
93 padding[i] = 0;
94 }
95
96 byte[] temp = new byte[in.length +length];
97 byte[] blocks = new byte[16];
98
99 Kunci = KeyExpansion(secret,nk);
100 int hitung = 0;
101 for(i=0;i<in.length + length; i++){
102 if(i>0 && i%16 == 0){
103 blocks = EncryptBlock(blocks,Kunci);
104 System.arraycopy(blocks,0,temp,i-16,blocks.length);
105 }
106 if(i < in.length){
107 blocks[i%16] = in[i];
108 }else{
109 blocks[i%16] = padding[hitung%16];
110 hitung++;
111 }
112 }
113 if(blocks.length == 16){
114 blocks = EncryptBlock(blocks,Kunci);
115 System.arraycopy(blocks,0,temp,i-16,blocks.length);
116 }
117
118 return temp;
119 }
120
121
122 public static byte[] EncryptBlock(byte[] in, byte[][] password){ //Enkripsi per blok
123 byte[] out = new byte[16];
124 //inisiasi state
125 byte[][] state = new byte[4][nb];
126
127 for (int i = 0; i<4;i++ ) {
128 for(int j=0;j<nb;j++){
129 state[i][j] = in[i+j*4];
130 //System.out.printf(" %d", state[i][j]);
131 }
132 }
133
134 System.out.printf("Sesudah:\n");
135 state = AddRoundKey(state,password,0); //Proses AddRoundKey pertama
136
137
138 //Looping Standard Round
139 int round; //nr-1
140 for(round=1;round<nr;round++){
141 state = ByteSub(state);
142 state = ShiftRow(state);
143 state = MixColumn(state);
144 state = AddRoundKey(state,password,round);
145 }
146
147 //Proses final round
148 state = ByteSub(state);
149 state = ShiftRow(state);
150 state = AddRoundKey(state,password,nr);
151
152 //Memasukkan isi state ke dalam output
153 for(int i=0;i<in.length;i++){
154 out[i%4*4+i/4] = state[i/4][i%4];
155 }
156
157 return out; //Mengembalikan hasil enkripsi perblok
158 }
159
160
161 //Proses AddRoundKey
162 private static byte[][] AddRoundKey(byte[][] state, byte[][] secret, int round){
163
164 byte[][] temp = new byte[state.length][state[0].length];
165
166 for(int j=0;j<nb;j++){
167 for(int i=0;i<state[j].length;i++){
168 temp[j][i] = (byte) (state[j][i] ^ secret[round*nb+j][j]);
169 }
170 }
171
172 return temp;
173 }
174
175
176 //Proses SubByte
177 private static byte[][] ByteSub(byte[][] state){
178 // System.out.println(state.length);
179 // System.out.println(state[0].length);
180
181 byte[][] temp = new byte[state.length][state[0].length];
182
183 for(int i=0;i<4;i++){
184 for(int j=0;j<nb;j++){
185 int plot = state[i][j];
186 //System.out.println(plot);
187 //System.out.println(plot);
188 temp[i][j] = (byte) (sbox[plot & 0x000000ff] & 0xff);
189 //System.out.printf("isi state: %d, i = %d, j = %d, isi sbox = %d, baris sbox = %d, kolom sbox = %d\n",state[i][j],i,j,s_box[plot/16][plot%16],plot/16,plot%16);
190
191 //System.out.println(plot);
192 //System.out.print(plot%16 + " ");
193 }
194 }
195
196 return temp;
197
198 }
199
200 //Proses MixColumn
201 private static byte[][] MixColumn(byte[][] state){
202 int[] MixColumnMatrix = new int[4];
203 byte b2 = (byte) 0x02, b3 = (byte)0x03;
204 for(int j = 0;j<4;j++){
205 MixColumnMatrix[0] = Gmul(b2,state[0][j]) ^ Gmul(b3,state[1][j]) ^ state[2][j] ^ state[3][j];
206 MixColumnMatrix[1] = state[0][j] ^ Gmul(b2, state[1][j]) ^ Gmul(b3, state[2][j]) ^ state[3][j];
207 MixColumnMatrix[2] = state[0][j] ^ state[1][j] ^ Gmul(b2,state[2][j]) ^ Gmul(b3,state[3][j]);
208 MixColumnMatrix[3] = Gmul(b3,state[0][j]) ^ state[1][j] ^ state[2][j] ^ Gmul(b2, state[3][j]);
209
210 for(int i=0;i<4;i++){
211 state[i][j] = (byte)(MixColumnMatrix[i]);
212 }
213
214 }
215
216 return state;
217
218 }
219
220 //Proses perkalian matriks
221 public static byte Gmul(byte a, byte b) {
222 byte aa = a, bb = b, r=0, t;
223 while(aa !=00){
224 if((aa&1) != 0){
225 r = (byte)(r^bb);
226 }
227 t = (byte)(bb & 0x80);
228 bb = (byte) (bb << 1);
229 if(t != 0 ){
230 bb = (byte)(bb ^ 0x1b);
231 }
232 aa = (byte)((aa & 0xff) >> 1);
233 }
234
235 return r;
236 }
237
238
239
240 //Proses ShiftRow
241 private static byte[][] ShiftRow(byte[][] state){
242
243 byte[] t = new byte[4];
244 for(int i=0;i<4;i++){
245 for(int j=0;j<nb;j++){
246 t[j] = state[i][(j+i)%nb];
247 //System.out.printf("Sebelum state: %d i: %d dan j: %d q: %d\n",state[i][j],i,j,(j+i)%nb);
248 }
249 for(int j=0;j<nb;j++){
250 state[i][j] = t[j];
251 //System.out.printf("Sesudah state: %d i: %d dan j: %d q: %d\n",state[i][j],i,j,(j+i)%nb);
252 }
253 }
254 return state;
255 }
256
257
258 /*Proses Ekspansi Kunci*/
259 private static byte[][] KeyExpansion(byte secret[],int Nk){
260 byte[][] w = new byte[nb*(nr+1)][4];
261 //byte[] temp = new byte[4];
262 int i=0;
263 while(i<Nk){
264 w[i][0] = secret[i*4];
265 w[i][1] = secret[i*4+1];
266 w[i][2] = secret[i*4+2];
267 w[i][3] = secret[i*4+3];
268
269 i++;
270 }
271
272 i = Nk;
273 while(i<nb*(nr+1)){
274 //temp = w[i-1];
275 byte[] temp = new byte[4];
276 for(int k=0;k<4;k++){
277 temp[k] = w[i-1][k];
278 }
279 if(i%Nk==0){
280 temp = SubWord(RotWord(temp));
281 temp[0] = (byte) (temp[0] ^ rcon[i/Nk] &0xff);
282 }else if((Nk > 6) && (i%Nk==4)){
283 temp = SubWord(temp);
284 }
285 w[i] = xor_func(w[i-Nk],temp);
286 i++;
287 }
288 return w;
289
290 }
291
292
293 public static byte[] SubWord(byte[] w){
294 byte[] aftersub = new byte[w.length];
295 for(int i=0;i<aftersub.length;i++){
296 aftersub[i] = (byte) (sbox[w[i] & 0x000000ff] & 0xff);
297 }
298
299 return aftersub;
300 }
301
302 public static byte[] RotWord(byte[] w){
303 byte[] afterRot = new byte[w.length];
304 for(int i=0;i<3;i++){
305 afterRot[i] = w[i+1];
306 }
307 afterRot[3] = w[0];
308 return afterRot;
309 }
310
311/* Proses Dekripsi */
312
313 public static byte[] Decrypt(byte[] in, byte[] secret){ //Prosedur dekripsi encrypted text
314 int i;
315 byte[] temp = new byte[in.length];
316 byte[] blocks = new byte[16];
317 nb = 4;
318 nk = secret.length/4;
319 nr = nk+6;
320 Kunci = KeyExpansion(secret,nk); //Mengambil Kunci sesi dari Key Expansion
321
322 for(i=0;i<in.length;i++){
323 if(i > 0 && i %16==0){
324 blocks = DecryptBlocks(blocks,Kunci); //Dekripsi text per blok dengan kunci sesi
325 System.arraycopy(blocks,0,temp,i-16,blocks.length); //Isi temp dengan blok terdeskripsi
326 }
327 if(i < in.length){
328 blocks[i%16] = in[i];
329 }
330
331 }
332 blocks = DecryptBlocks(blocks,Kunci); //Melakukan dekripsi text untuk blok terakhir
333 //Log.d("temp length:", String.valueOf(temp.length));
334 System.arraycopy(blocks,0,temp,i-16,blocks.length);
335 Log.d("temp isi: ", Arrays.toString(temp));
336 temp = DeletePadding(temp);
337 return temp;
338 }
339
340
341public static byte[] DecryptBlocks(byte[] in, byte[][] password){ //Dekripsi per blok
342 byte[] out = new byte[in.length];
343 byte[][] state = new byte[4][nb];
344 for (int i = 0; i<4;i++ ) {
345 state[i/4][i%4] = in[i%4*4+i/4];
346 }
347
348 state = AddRoundKey(state,password,nr);
349 int round;
350 for(round = nr-1;round <= 1;round--){
351 state = InvShiftRows(state);
352 state = InvSubBytes(state);
353 state = AddRoundKey(state,password,round);
354 state = InvMixColumns(state);
355 }
356 state = InvShiftRows(state);
357 state = InvSubBytes(state);
358 state = AddRoundKey(state,password,0);
359
360
361 for(int i=0;i<in.length;i++){
362 out[i%4*4+i/4] = state[i/4][i%4];
363 }
364
365 return out;
366 }
367
368
369 //Fungsi XOR
370 private static byte[] xor_func(byte[] a, byte[] b) {
371 byte[] out = new byte[a.length];
372 for (int i = 0; i < a.length; i++) {
373 out[i] = (byte) (a[i] ^ b[i]);
374 }
375 return out;
376
377 }
378
379 //Proses Inverse Shift Rows
380 private static byte[][] InvShiftRows(byte[][] state){
381 byte[] t = new byte[4];
382
383 for(int i=0;i<4;i++){
384 for(int j=0;j<nb;j++){
385 t[(j+i)%nb] = state[i][j];
386 //System.out.printf("Sebelum state: %d i: %d dan j: %d q: %d\n",state[i][j],i,j,(j+i)%nb);
387 }
388 for(int j=0;j<nb;j++){
389 state[i][j] = t[j];
390 //System.out.printf("Sesudah state: %d i: %d dan j: %d q: %d\n",state[i][j],i,j,(j+i)%nb);
391 }
392 }
393 return state;
394 }
395
396 //Proses Inverse Sub Bytes
397 private static byte[][] InvSubBytes(byte[][] state){
398 for(int i=0;i<4;i++){
399 for(int j=0;j<nb;j++){
400 byte plot = state[i][j];
401 state[i][j] = (byte) (invsbox[plot & 0x000000ff] & 0xff);;
402 // System.out.println(state[i][j]);
403 //System.out.print(plot%16 + " ");
404 }
405 }
406
407 return state;
408
409 }
410
411 //Proses Inverse Mix Columns
412 private static byte[][] InvMixColumns(byte[][] state){
413 int[] InvMixColumns = new int[4];
414 byte be = (byte) 0x0e, bb = (byte)0x0b, bd = (byte)0x0d,b9 = (byte)0x09;
415 for(int j =0;j<4;j++ ){
416 InvMixColumns[0] = Gmul(be,state[0][j]) ^ Gmul(bb,state[1][j]) ^ Gmul(bd,state[2][j]) ^ Gmul(b9,state[3][j]);
417 InvMixColumns[1] = Gmul(b9,state[0][j]) ^ Gmul(be,state[1][j]) ^ Gmul(bb,state[2][j]) ^ Gmul(bd,state[3][j]);
418 InvMixColumns[2] = Gmul(bd,state[0][j]) ^ Gmul(b9,state[1][j]) ^ Gmul(be,state[2][j]) ^ Gmul(bb,state[3][j]);
419 InvMixColumns[3] = Gmul(bb,state[0][j]) ^ Gmul(bd,state[1][j]) ^ Gmul(b9,state[2][j]) ^ Gmul(be,state[3][j]);
420
421 for(int i=0;i<4;i++){
422 state[i][j] = (byte)InvMixColumns[i];
423 }
424 }
425 return state;
426 }
427
428 //Proses Generate kunci
429 public static byte[] KeyGen(){
430 String secret = new String();
431 byte[] sec = new byte[secret.length()];
432 try{
433 KeyGenerator keygen = KeyGenerator.getInstance("AES");
434 keygen.init(128);
435 SecretKey secretKey = keygen.generateKey();
436 sec = secretKey.getEncoded();
437 }catch (NoSuchAlgorithmException e){
438 e.printStackTrace();
439 }
440 return sec;
441 }
442
443 //Menghapus Padding
444 public static byte[] DeletePadding(byte[] in){
445 int count = 0;
446 int i = in.length - 1;
447 while(in[i] == 0){
448 count++;
449 i--;
450 }
451
452 byte[] temp = new byte[in.length-count-1];
453 System.arraycopy(in,0,temp,0,temp.length);
454 return temp;
455 }
456}