S
S
Sanchoys2282021-07-05 16:08:14
Python
Sanchoys228, 2021-07-05 16:08:14

How to add a paid subscription to your program?

What are the ways to implement a subscription through an activation key? It is necessary that the program requests the key itself in a month, for example. And how to teach her to check the authenticity of the key (she knew how to recognize her keys)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Matvey Polubryukhov, 2021-07-06
@matveypol003

Hello. You can request a key with an interval of 1 month like this:

import calendar
from datetime import date, timedelta

today = date.today()
days = calendar.monthrange(today.year, today.month)[1]
next_month_date = today + timedelta(days=days)

( Python3 | How to add a month to a date? )
1. When entering a key, write next_month_date to a file (preferably in binary form, so that it cannot be changed in notepad. You can use pickle);
2. At the next start of the program, read the saved file with the date and compare it with the current one;
3. If 1 month has passed, then go to step 1. If not, run the main program.
I'm answering your second question (about recognizing 'own' keys).
You can create hashes (like SHA) for all keys and store them in another file (possibly in a text file). When entering a key (before performing step 1), calculate the hash of the entered key and try to find it in the file with hashes. If it is there - fine, go to step 1. If not, we show an error message.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question