# WOL Apgar Routine

![](https://cdn.hashnode.com/uploads/posts/6aefcf97a529a56101dcc7c8/e9117ac0-41ad-48ce-a2d8-bf2c909f4868.jpg)

Westwood Studios © EA

APGAR is an encrypted token sent to the server to identify a user’s password. This is a one-way encryption routine and cannot be decrypted. All legacy Command and Conquer game client passwords using this algorithm must be exactly 8 characters long.

### Psuedo-code implementation



```
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
```



### PHP Implementation (Sean Wragg)

### Javascript Implementation (Sean Wragg)

### C++ Implementation (RenegadeProjects.com)

### mIRC Script Implementation (Frank Razenberg)

*Originally published at* [*seanwragg.com*](http://seanwragg.com/2010/08/25/wol-apgar-routine/) *on August 26, 2010.*
