Beispiel #1
0
  /** Creates a new instance of War3Decode */
  public War3Decode(String cdkey) {
    byte[] table = new byte[W3_BUFLEN];
    int[] values = new int[4];
    tableLookup(cdkey.toUpperCase(), table);

    for (int i = W3_BUFLEN; i > 0; i--) Mult(4, 5, values, values, table[i - 1]);

    // -------------

    decodeKeyTablePass1(values);

    decodeKeyTablePass2(values);

    product = values[0] >> 0x0a;
    // val1 = ((values[0] & 0x03FF) << 0x10) | (values[1] >> 0x10);
    // val1 = IntFromByteArray.LITTLEENDIAN.getInteger(values, 0);
    val1 = ((values[0] & 0x03FF) << 0x10) | (values[1] >>> 0x10);

    val2 = new byte[10];
    val2[0] = (byte) ((values[1] & 0x00FF) >> 0);
    val2[1] = (byte) ((values[1] & 0xFF00) >> 8);

    IntFromByteArray.LITTLEENDIAN.insertInteger(val2, 2, values[2]);
    IntFromByteArray.LITTLEENDIAN.insertInteger(val2, 6, values[3]);
  }
Beispiel #2
0
  public int[] getKeyHash(int clientToken, int serverToken) {
    try {
      MessageDigest digest = MessageDigest.getInstance("SHA-1");

      byte[] warBuf = new byte[26];

      IntFromByteArray.LITTLEENDIAN.insertInteger(warBuf, 0, clientToken);
      IntFromByteArray.LITTLEENDIAN.insertInteger(warBuf, 4, serverToken);
      IntFromByteArray.LITTLEENDIAN.insertInteger(warBuf, 8, getProduct());
      IntFromByteArray.LITTLEENDIAN.insertInteger(warBuf, 12, getVal1());

      for (int i = 16; i < 26; i++) warBuf[i] = getWar3Val2()[i - 16];

      digest.update(warBuf);
      return IntFromByteArray.LITTLEENDIAN.getIntArray(digest.digest());

    } catch (java.security.NoSuchAlgorithmException e) {
      System.out.println("Could not find SHA1 library " + e);
      System.exit(1);
      return new int[1];
    }
  }