ModEnc is currently in Maintenance Mode: Changes could occur at any given moment, without advance warning.

XWIS:APGAR

From ModEnc
Revision as of 23:34, 18 June 2008 by 88.159.77.125 (talk)
Jump to: navigation, search

APGAR is a token sent by a C&C game to tell XWIS the players' password. The password is encrypted using a weak algorithm.

Example (decrypted password "reneproj"):

apgar Ykbcaxop 0

The closing zero seems to have a special function.

Algorithm to calculate encrypted password:

string apgar(string input) {
  lookup = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  out = ""
  i = 1
  while (i <= 8) {
    left = input[i]
    right = input[length[input] - i + 1]

    x = left & 1 ? ((left << 1) ^ (left & 1)) & right : left ^ right

    out += lookup[x & 63]
    i++
  }
  return out
}