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

Difference between revisions of "XWIS:APGAR"

From ModEnc
Jump to: navigation, search
m (True pw)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
APGAR is a token sent by a C&C game to tell XWIS Online the players password. The password is encrypted with an unknown method.
+
APGAR is a token sent by a C&C game to tell XWIS the players' password. The password is encrypted using a weak algorithm. This is a one-way encryption, i.e. you cannot find the original password from it's encrypted form.
 +
 
 +
Pseudo-code to calculate the password from an 8 letter input:
 +
<pre>
 +
function apgar(input)
 +
  lookup = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
 +
  out = ""
 +
  i = 1
 +
  while (i <= 8)
 +
    left = ascii value of input[ i ]
 +
    right = ascii value of input[ length[input] - i ]
 +
 
 +
    if left is odd
 +
        x = ((left * 2) XOR (left AND 1)) AND right
 +
    else
 +
        x = left XOR right
 +
 
 +
    out += lookup[x AND 63]
 +
    i++
 +
 
 +
  return out
 +
</pre>
 +
 
 +
A C++ implementation of this algorithm:
 +
<pre>
 +
std::string apgar(std::string input) {
 +
  std::string lookup = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
 +
  std::string out = "";
 +
  int i = 0;
 +
  while (i < 8) {
 +
    unsigned char left = input[i];
 +
    unsigned char right = input[input.length() - i];
 +
 +
    unsigned char x = left & 1 ? ((left << 1) ^ (left & 1)) & right : left ^ right;
 +
 +
    out += lookup[x & 63];
 +
    i++;
 +
  }
 +
  return out;
 +
}
 +
</pre>
  
 
Example (decrypted password "reneproj"):
 
Example (decrypted password "reneproj"):
Line 5: Line 45:
 
apgar Ykbcaxop 0
 
apgar Ykbcaxop 0
 
</pre>
 
</pre>
The closing zero seems to have a special function.
+
 
 +
The closing zero seems to have no special function.
  
 
[[Category:XWIS Protocol]]
 
[[Category:XWIS Protocol]]

Latest revision as of 00:06, 19 June 2008

APGAR is a token sent by a C&C game to tell XWIS the players' password. The password is encrypted using a weak algorithm. This is a one-way encryption, i.e. you cannot find the original password from it's encrypted form.

Pseudo-code to calculate the password from an 8 letter input:

function apgar(input)
  lookup = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  out = ""
  i = 1
  while (i <= 8)
    left = ascii value of input[ i ]
    right = ascii value of input[ length[input] - i ]

    if left is odd 
        x = ((left * 2) XOR (left AND 1)) AND right
    else
        x = left XOR right

    out += lookup[x AND 63]
    i++
  
  return out

A C++ implementation of this algorithm:

std::string apgar(std::string input) {
  std::string lookup = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  std::string out = "";
  int i = 0;
  while (i < 8) {
    unsigned char left = input[i];
    unsigned char right = input[input.length() - i];
 
    unsigned char x = left & 1 ? ((left << 1) ^ (left & 1)) & right : left ^ right;
 
    out += lookup[x & 63];
    i++;
  }
  return out;
}

Example (decrypted password "reneproj"):

apgar Ykbcaxop 0

The closing zero seems to have no special function.