I'm still trying to translate some VB6 code to Python. However the way VB6 can read lists, I cannot properly do the same thing in Python. Here is the Python code I've gotten so far.

RIght now the arrayKey value is wrong. It should be something like:Code:def starkey(self, key): a_list = list() is_valid = [False] for i in range(1, 14): arrayKey[i - 1] = key[i:0] v = 3 for i in range(0, 12): c = arrayKey.append(i) n = val(c) n2 = v * 2 n = n ^ n2 v = v + n v = v % 10 if hex(v) == arrayKey.append(12): is_valid[0] = True v = 194 for i in range(11, 0, -1): if v < 7: v2 = 0x13AC9741 for i in range(11, 1, -1): c = arrayKey.append(i.upper()) arrayKey[i] = c if ord(c) <= ord('7'): v = v2 c2 = v and 0xFF c2 = c2 and 7 c2 = c2 ^ c v = int(v) >> 3 arrayKey[i] = c2 v2 = v elif ord(c) < 65: c2 = int(i) c2 = c2 and 1 c2 = c2 ^ c arrayKey[i] = c2 c = arrayKey.append(i) n = int(v/12) n2 = v % 12 v = v - 17 c2 = arrayKey.append(n2) arrayKey[i] = c2 arrayKey[n2] = c

While a_list = list().Code:a_list.append(item)

The problem is that I can't do a lot of this code without errors. Where the function has:

I tried doing:Code:for i in range(1, 14): arrayKey[i - 1] = key[i:0]

I used 5 as i in range(1, 14) just for testing. The key is 13 numbers, but they are in a string, for instance, key = '1234567890123'. Does anyone know an alternative solution to this list problem? Just incase you need the VB6 code, here it is:Code:>>> a_list = list() >>> a_list.append(5) >>> a_list[5 - 1] = key[5:0] Traceback (most recent call last): File "<pyshell#54>", line 1, in ? a_list[5 - 1] = key[5:0] IndexError: list assignment index out of range >>>

Thanks.Code:Public Function DecodeStarcraftKey(ByVal sKey As String) As String On Error Resume Next Dim R As Double, n As Double, n2 As Double, v As Double, _ v2 As Double, keyvalue As Double, c1 As Byte, c2 As Byte, c As Byte, _ bValid As Boolean, i As Integer, aryKey(0 To 12) As String For i = 1 To 13 aryKey(i - 1) = Mid$(sKey, i, 1) Next i v = 3 For i = 0 To 11 c = aryKey(i) n = Val(c) n2 = v * 2 n = n Xor n2 v = v + n Next i v = v Mod 10 If Hex(v) = aryKey(12) Then bValid = True End If v = 194 For i = 11 To 0 Step -1 If v < 7 Then GoTo continue c = aryKey(i) n = CInt(v / 12) n2 = v Mod 12 v = v - 17 c2 = aryKey(n2) aryKey(i) = c2 aryKey(n2) = c Next i continue: v2 = &H13AC9741 For i = 11 To 0 Step -1 c = UCase$(aryKey(i)) aryKey(i) = c If Asc(c) <= Asc("7") Then v = v2 c2 = v And &HFF c2 = c2 And 7 c2 = c2 Xor c v = RShift(CLng(v), 3) aryKey(i) = c2 v2 = v ElseIf Asc(c) < 65 Then c2 = CByte(i) c2 = c2 And 1 c2 = c2 Xor c aryKey(i) = c2 End If Next i DecodeStarcraftKey = Join(aryKey, "") Erase aryKey() End Function

Tweet This+ 1 thisPost To Linkedin