How to make automatic code changer?

snic

Beta member
Messages
1
Location
georgia
Hello in the first place, I want to know how to create automatic code changer or generator don't know what it's called exactly but it should do following. When my client buys my product it will redirect him/her to the page where will be specific code like ( a15kuf6e or something like that) which will change every time new costumer purchases something.
Thanks in advance
 
You men registration/serial code type generation.

what's this code going to be for? I mean will your software be unregistered without it?

If you're writing and selling a product that requires a serial code to be generated then you've probably already got some kind of process for generating serials? (manual or a separate program?) all you have to do is take that logic and put it into a web page.


if the question is a bit more broad than that (like how do you write software that's crippled or won't run unless it has a serial number, then your serial generator has to match up with the software that you're licensing...)

you see how writing the website to give out the codes might be starting at the wrong end of the problem...

when you've figured out how to write the software that requires a serial key, then generating a serial key becomes the easy bit! -because you know what the program is looking for.

or are you looking for some kind of support number?
(like you are customer number ####,)

in that case, if you;re assigning customers customer numbers that are unique you should probably store them in a database, and they should be sequential rather than random, and form a unique ID in the table (possibly the primary key linking order IDs to customer details and order details)...

Again, when you're written the site for customers to add their details to buy the products etc, just retrieving the auto-incremented field is a pretty simple job.
 
You're basically describing a transaction reference code. Presumably you don't want this to be sequential otherwise you wouldn't have asked, therefore I'd suggest the following:

1) Query any suitable PRNG (pseudo-random-number-generator) function from a reputable crypto library (openssl, etc.) for a new value
2) feed this value into a hash function (e.g. SHA-1, md5 etc.) - again, available from your crypto library
3) take the first n bytes of the resulting alphanumeric string (these strings are hexadecimal numbers) - say around 8-10 - too long a substring will be take more space in a database to key on and be prone to mis-quoting by customers calling support staff, whereas too short a string increases the probability of a 'hash collision' (i.e. a duplicate). Therefore it's worth being too long than too short.
4) use this 8-10 (or whatever you choose) substring to key your database and store all your required transaction information (product id, quantity, unit price, total price, customer id etc.) alongside it.

One thing I would say, irrespective of the above suggestion, is that if you're not clear on exactly what your system design is (which since you're asking this question you won't be), make sure to seek some professional review of your architecture, database model and associated code. It is very easy to make mistakes in this sort of software which could lead to a lot of headaches for you and your customers down the line.
 
Back
Top Bottom