2

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 and lower-case characters?

kmalmur
  • 2,809
  • 3
  • 29
  • 37
  • I don't know the answer but I suggest that you have to be careful about limiting what charaters you use, I can see many users having problems reading it correctly if it can be any of `I`, `l` and `1` etc. – Hans Olsson Jun 05 '10 at 10:42
  • Making it case sensitive is also probably a bad idea. – Joren Jun 05 '10 at 10:49
  • I will use base 32 to avoid these problems. – kmalmur Jun 05 '10 at 11:39

2 Answers2

3

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

Community
  • 1
  • 1
PaulG
  • 13,871
  • 9
  • 56
  • 78
1

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.

Rupeshit
  • 1,476
  • 1
  • 14
  • 23