· 7 years ago · Nov 26, 2018, 02:24 PM
1public static void main(String[] args) {
2 // TODO code application logic here
3 int mida = 192;
4 byte[] enc = {(byte)0xEC, (byte)0xC4, (byte)0xD5, (byte)0x89,
5 (byte)0x02, (byte)0xE3, (byte)0xD5, (byte)0xCC,
6 (byte)0x5E, (byte)0xC6, (byte)0xAF, (byte)0x6C,
7 (byte)0x61, (byte)0x8B, (byte)0xC2, (byte)0xA5};
8 for (int i =0; i<10000; i++){
9 String clave = Integer.toString(i);
10 while (clave.length()<4){
11 clave= "0"+clave;
12 }
13 SecretKey s2 = Xifrat.generarClau(clave, mida);
14 try {
15 Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
16 cipher.init(Cipher.DECRYPT_MODE, s2);
17 byte[] dadesDesencriptades = cipher.doFinal(enc);
18 System.out.println("String usada: " + clave + " resultado: " + new String(dadesDesencriptades));
19 //System.out.println(new String(dadesDesencriptades));
20 } catch (Exception ex) {
21 }
22 }
23 }