开发者

How to create serial number generator? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, over开发者_开发技巧ly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

How can I program a Serial Number Generator that generates serial numbers for some existing software?


You don't state any specific requirements but you can use a GUID.

Guid mySerialNumber = Guid.NewGuid();


I have used this CodeProject Article before when I've needed to do the same thing for projects I have worked on recently. I found it very detailed and while I didn't use everything in the sample I did get a lot out of it. (I have no affiliation with CodeProject or the author)

Additionally there is a library which gives you all this functionality complete with license file replacement and heaps of other features, but its not free, and unfortunately I couldn't remember the link. I'm sure a bit of Googgling and you'll find it.


public static string GetSerialKeyAlphaNumaric(SNKeyLength keyLength)
{
    string newSerialNumber = "";
    string SerialNumber=Guid.NewGuid().ToString("N").Substring(0, (int)keyLength).ToUpper(); 
    for(int iCount=0; iCount < (int) keyLength   ;iCount +=4)
        newSerialNumber = newSerialNumber + SerialNumber.Substring(iCount, 4) + "-";
    newSerialNumber = newSerialNumber.Substring(0, newSerialNumber.Length - 1); 
    return newSerialNumber;
}


Try a number you can test using Luhn's algorithm. That way, you can make it long an inscrutable, yet still easily confirmed. The article contains a link to a C# implementation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜