• C

Serial number validation code

Can anyone send me working C code for some advanced serial number checking algorithm. I want certain number of serial numbers to be reserved in advance, it is not necessary to extract the user's name from it though. Thanks in advance.
LVL 2
alexxxAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tovergaardCommented:
One common method to checking serial numbers is to use a hash algorithm. A hash algorithm is a one-way function, this means you calculate a sort of checksum, but it is not possible to calculate the serialnumber if the hash value is known.

I am sure you will the sourcecode to a hash algorithm can be found at the Internet.
0
alexxxAuthor Commented:
Thank you tovergaard. I'm sorry for not accepting your answer. If I use some sort of hash function (& check the calculated value against some unique predefined value) then how do I guarantee that I can find at least N valid serial numbers? What's more, to use this technique I need an algorithm to generate valid serial numbers with acceptable growth rate - straightforward iteration over all values and checking their hash value just won't do. I beleive the solution to this is to use some encryption technique based on prime numbers or something of the kind. Unfortunatly I have no time to get into all this theory, what I want is the C code which does this job more or less with a bit of explanation to get me started. Thank you.
0
msmitsCommented:
What you can do is give out a serial number and key value.
Inside you program you encode the serial number with some secret code (can be simple like concatenation of both or alternating bytes of both) and then running this through the md5 algorithm.
The result of this should then be equal to the key value you gave out with the serial number.
You have a special program for yourself that does the same to generate the keys for the serial numbers you invent.

Source code for the md5 algorithm can be found with the RFC that describes it. Look at altavista for 'md5 +source' and the third item is:

  http:/wsspinfo.cern.ch/sec/tools/md5

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.