Python key gen that can be used 1 time and check its valid
Question:
Hey im learning python and i would like to make a script that requires a licence key, but i want to make it require a personal key, for example they would have to purchase the programme/key to then proceed to the next stage. but i want it so that the key is generated and can only be used once.
activeKey = "Test"
enterActiveKey = input("Please enter the activation key down below:\n")
if activeKey == enterActiveKey:
print("Activation key is successful.")
while activeKey != enterActiveKey:
print("Activation key is incorrect. Please re-run the program")
break
I made this script that i can specifically chose a activation key but i want it so that the key is generated and only possible to be used 1 time so i dont need to specify the key.
Answers:
This cannot be done,because unique id generation is not possible, even UUID have collision risk,
So the best way is maintaining a Database,
As you say user have to purchase the key, this means you have a website so you can try
mysql,
mongodb atlas(free for some extend ) even sqlite,
any kind of database is ok,
See
tutorial for database connectivity
Here is the very basic flow:
*
- You generate any uuid key then store that in database
- When user purchase a key, update the database that this key is sold
- Now when user enter that key in your program check Database that if
this key is present and sold
you can now add your logic to make it better.
Hey im learning python and i would like to make a script that requires a licence key, but i want to make it require a personal key, for example they would have to purchase the programme/key to then proceed to the next stage. but i want it so that the key is generated and can only be used once.
activeKey = "Test"
enterActiveKey = input("Please enter the activation key down below:\n")
if activeKey == enterActiveKey:
print("Activation key is successful.")
while activeKey != enterActiveKey:
print("Activation key is incorrect. Please re-run the program")
break
I made this script that i can specifically chose a activation key but i want it so that the key is generated and only possible to be used 1 time so i dont need to specify the key.
This cannot be done,because unique id generation is not possible, even UUID have collision risk,
So the best way is maintaining a Database,
As you say user have to purchase the key, this means you have a website so you can try
mysql,
mongodb atlas(free for some extend ) even sqlite,
any kind of database is ok,
See
tutorial for database connectivity
Here is the very basic flow:
*
- You generate any uuid key then store that in database
- When user purchase a key, update the database that this key is sold
- Now when user enter that key in your program check Database that if
this key is present and sold
you can now add your logic to make it better.