开发者

.NET - alpha-numeric representation of numbers

I'm implementing serial key functionality in my application. User needs to enter at least 64bit number in order to register the application. Because typing number like 9,223,372,036,854,775,807 will take a while I want to compress it a bit. The first guess was to code this number hexadecimally but it still is quite long (0x7FFF FFFF FFFF FFFF).

Is there any standard method in .NET to code this number alphanumerically using for example: digits, upper-case 开发者_如何学Pythonand lower-case characters?


Base 64 is probably what you want. It allows all the uppercase and lowercase characters, and two symbol characters (+ and /)

Convert.ToBase64String will convert a number to a string.
Convert.FromBase64String converts string back to number.

Alternatively, if you want just uppercase characters (and digits 2-7) then you could use Base32, but there isnt a native implementation for that in .net. Some further info here : Base32 Decoding


If you want to add serial key functionality in your project then during the deployment you can add serial key.That is the standard way of .NET to add key.Create new deployment project and add user interface editor in that project.Then add customer information window in it. Then in its property you can put whatever pattern you want as a aplha numeric or only numeric whatever.The detail steps of doing this I mention in my blog you can refer it from here.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜