Valhalla Legends Forums Archive | Visual Basic Programming | sc encoding keys

AuthorMessageTime
Zer0
I have managed to get the keys decoded and all but i cant seem to get them re-encoded if someone would be willing to help me with this that would be great. I am also rather new to VB and still learning so, thx.

Zer0
September 13, 2006, 8:14 PM
rabbit
Reverse the algorithm.
September 13, 2006, 8:44 PM
Zer0
iv been trying but keep comming up with really weird output as soon as i get back from class ill post the code and see if i cant get it that way

edit: rabbit if ur the same person im thinkn of ur friends wit JTN (or jeff) arnt u?
September 13, 2006, 8:50 PM
l2k-Shadow
[code]

' Ported from C to VB by l2k-Shadow

Public Sub EncodeSCKey(ByRef CDKey As String, ByVal PublicValue As Long, ByVal PrivateValue As Long, Optional ByVal ProductValue As Long)
Dim tKey(11) As String, tStr As String, tlng As Long, hashKey As Long, pos As Integer, i As Integer
Dim tProduct As String, tPublic As String, tPrivate As String
    'Assemble values into a string
    If Product = 0 Then Product = 1
    If Len(Product) < 2 Then
        tProduct = CStr("0" & Product)
    Else
        tProduct = CStr(Product)
    End If
    tPublic = CStr(PublicValue)
    While Len(tPublic) < 7
        tPublic = "0" & tPublic
    Wend
    tPrivate = CStr(PrivateValue)
    While Len(tPrivate) < 3
        tPrivate = "0" & tPrivate
    Wend
    CDKey = tProduct & tPublic & tPrivate
    'Fill Array
    For i = 0 To 11
        tKey(i) = Mid$(CDKey, i + 1, 1)
    Next i
    'Final Vaues
    hashKey = &H13AC9741
    For i = 11 To 0 Step -1
        tStr = tKey(i)
        If Asc(tStr) <= 55 Then
            tKey(i) = (((hashKey And &HFF) And 7) Xor tStr)
            hashKey = hashKey \ 8
        ElseIf Asc(tStr) < 65 Then
            tKey(i) = ((i And 1) Xor tStr)
        End If
    Next i
    'Unshuffling
    For i = 7 To &HC2 Step &H11
        tlng = i Mod &HC
        tStr = tKey(tlng)
        tKey(tlng) = tKey(pos)
        tKey(pos) = tStr
        pos = pos + 1
    Next i
    'Calculate check digit
    tlng = 3
    For i = 0 To 11
        tlng = tlng + (tKey(i) Xor (tlng * 2))
    Next i
    CDKey = Join(tKey, vbNullString) & CStr(tlng Mod 10)
End Sub
[/code]
have fun
September 14, 2006, 1:57 AM
HeRo
Or use the search function that god gave to you and find:
https://davnit.net/bnet/vL/index.php?topic=14023.0
September 16, 2006, 11:32 PM
l2k-Shadow
[quote author=heRo link=topic=15689.msg158225#msg158225 date=1158449535]
Or use the search function that god gave to you and find:
https://davnit.net/bnet/vL/index.php?topic=14023.0
[/quote]

that's d2/w2 he was asking for sc.
September 16, 2006, 11:35 PM
Zer0
yes i was looking for SC also thank you shadow
September 20, 2006, 4:12 AM
HeRo
[quote author=Zer0 link=topic=15689.msg158488#msg158488 date=1158725540]
yes i was looking for SC also thank you shadow
[/quote]
I had a hunch  ;D
September 20, 2006, 4:19 AM

Search