- Home /
Creating a key generator
I would like the players of my game to be able to unlock promotional content and other special stuff by entering single-use key codes. How do I do this with Unity? How to generate the codes? And how can I check if the code has already been used by someone else?
Thanks in advance.
But how? I have no idea where to begin. Are there any examples I could take a look at?
This is an open question, best suited to be asked in Unity Forums. Plese read the FAQ before asking :)
Answer by -hiTo- · May 01, 2012 at 12:49 PM
Well, to keep track of which codes are used, and which are still usable, you need to have some sort of central online database.
To actually generate a key, several methods can be used. Just taking the name of the game in a string, salting it with the timestamp and some other cool nonsense characters makes a pretty good base for fiddling around with. Example being "My wonderful game" + "1335875079" + "AfeWExtRaChaRAcTers"
And what I mean by fiddling around is to change letters and numbers and possibly even special characters around with the help of an algorithm. It could be as simple as a substitute algorithm, where you replace all A's with B's and all 1's with 2's, or as complex as the SHA-1.
Or if you generate the keys on demand, you could just randomize 30 characters, see if it already exists in the database and if it doesn't, insert it. It's a bit less secure though, since people could actually make their own keys and even though they can't enter them into your database, they might get lucky and steal someone else' code.
Your answer
Follow this Question
Related Questions
[Error]Serial exceeds maximum number of activatsions 0 Answers
Terrain Toolkit - License 0 Answers
How do I recover my license key? 1 Answer
(Legal) Standalone Player "About Dialogue" Unity3d 4.x 1 Answer
Unity license mistake 2 Answers