Ask coding questions

← Back to all posts
Trying to make a redeemable license application in python

Hey guys, I’m trying to make a redeemable license application in python.
if the user pastes the correct string, he can get access to the application.
But if not, he gets rejected.
how can i make that ?

Answered by SixBeeps [earned 5 cycles]
View Answer

Well, you'll need a large list of valid keys and whether or not they have been used. There are many ways of doing that, but the most sensical way is with a database.

Each database entry has a key and a value. For your purpose, you might want to have the generated key as the key (no surprise) and either True/False as the value.

When the user enters a key, check with the database. If that key doesn't exist, they're entering in an invalid key. If it is in there, check if it is either true or false. If it's false, then grant them access, then set the value to true. If it's true, then you know the key has already been used. You may do whatever you want with that information.

Alternatively if that's too hard for you to handle, you can always just use a dictionary in place of a database.


@SixBeeps ohhh okay yes.
what database would you suggest?


@OnTop ReplDB should work for your use case, but if you want something sturdier, you could always give Firebase a try.