Generar clave

Iniciado por chchdc, 17 Julio 2012, 16:22 PM

0 Miembros y 1 Visitante están viendo este tema.

chchdc

Hola,
Estoy intentando obtener la clave de un programa en java, podeis ayudarme:
Código (java) [Seleccionar]
private int securityTest(String s, String s1)
   {
       byte abyte0[] = new byte[s1.length()];
       abyte0 = s1.getBytes();
       if(s1.length() != 11)
           return -1;
       for(int i = 0; i < 11; i++)
       {
           if(abyte0[i] >= 97)
           {
               abyte0[i] += -61;
               continue;
           }
           if(abyte0[i] >= 65)
               abyte0[i] += -55;
           else
               abyte0[i] -= 48;
       }

       long l = 0L;
       for(int j = 1; j <= 9; j++)
           l = l * 62L + (long)abyte0[j];

       int k = 0;
       int i1 = 1;
       for(int j1 = 10; j1 >= 0; j1--)
       {
           k += abyte0[j1] * i1;
           i1 ^= 2;
       }

       k %= 62;
       String s2 = String.valueOf(l);
       if(abyte0[0] != 11 || k != 0)
           return -1;
       return s.compareTo(s2) != 0 ? 0 : 1;
   }


Se supone que yo conozco s, pero no s1, que es la clave que necesito obtener.

MCKSys Argentina

Si mis ojos no me engañan, s no se usa en el codigo.

Ademas, calcular s1 en base a este codigo es muy sencillo.

Estudia el codigo. Miralo por partes. Cuando comprendas que es lo que hace cada parte del programa, podras invertirlo y asi podras calcular el string...

MCKSys Argentina

"Si piensas que algo está bien sólo porque todo el mundo lo cree, no estás pensando."


chchdc

El valor de s = 352053048488707
Como actuo? Pruebo todas las combinaciones posible hasta encontrar s1?