Author | Message | Time |
---|---|---|
MysT_DooM | well past few months i've been tryin to crack the cd key algorithm. I have found many similarties in many keys. anywayz I want to know how to generate a fixed number. ex) Generate 13 digits randomly , whose 7th digit is always 0 and digits 1-12 are less than or equal to 8 All help would be greatly appreciated. | December 18, 2005, 9:06 PM |
FrOzeN | Assuming this is for StarCraft. You should first have a look at [u]this topic[/u], as theres alot of discussion on it there. As for a simple function to do this, here's something I just threw together on the spot. [code]Private Function GenerateCdKey() As String Dim CdKey As String Randomize CdKey = Replace(CStr(CLng(Rnd * 999999 + 100000)) & "0" & CStr(CLng(Rnd * 999999 + 100000)), "9", CStr(CInt(Rnd * 9))) GenerateCdKey = CdKey End Function[/code] Not exactly the best coding, but it works. Also it would be a good idea check the key generated each time with the validation code disassembled from the installer. Info on that is also in the StarCraft Keys thread, links ([u]here[/u] and [u]here[/u]). [EDIT] Just noticed you said you want the digits 1-12 less than 9, before I though you ment the other 12 digits leaving the 7th 0. Anyway the code would then look like this: [code]Private Function GenerateCdKey() As String Dim CdKey As String Randomize CdKey = Replace(CStr(CLng(Rnd * 999999 + 100000)) & "0" & CStr(CLng(Rnd * 99999 + 100000)), "9", CStr(CInt(Rnd * 9))) & CStr(CInt(Rnd * 10)) GenerateCdKey = CdKey End Function[/code] | December 19, 2005, 3:52 AM |