• Welcome to Valhalla Legends Archive.
 

[Python] Decode Cdkey

Started by Yegg, April 17, 2005, 09:43 AM

Previous topic - Next topic

Yegg

I haven't touched this function in a very long time, but the latest implementation of it I have on my computer is the one below. It doesn't do the checksum to verify if the key is valid and it doesn't split the key into its 3 values in this, I did those tasks in separate functions.

def decodeStarcraftKey(key):
    arrayKey = list(key)
    n = 11
    v = 0x13AC9741
    for i in (8, 10, 4, 5, 7, 1, 11, 3, 9, 2, 0, 6):
        c = int(key[i])
        if c < 7:
            c = v & 0xFF & 7 ^ c
            v >>= 3
        else:
            c = n & 1 ^ c
        arrayKey[n] = c
        n -= 1
    return ''.join(map(str, arrayKey))