Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the source for Python's datetime?

I'm creating a license that allows a user to use a Python program for a specific period of time. The program uses datetime.today() to check the current date and then compares it to the expiration date encrypted in the license. If the current date is past the expiration date, it fails to run.

My concern is, what if someone manipulates his PC's time to make the program think the license is still valid? Does Python datetime library use PC's time? If not, what's the source for it?

Thanks in advance!

like image 306
currentlyunknown Avatar asked Nov 30 '25 02:11

currentlyunknown


1 Answers

datetime.today() uses system date/time. So yes, a user can change the system time to trick the program.

You can use a library like ntplib to get the time from a remote server, but of course this requires a network connection. So you may want to decide how to deal with a situation when your program doesn't have network access: maybe you only ping the server every week or so and require that the application be connected to the internet at least once per week.

A better solution would be to give your user a product key they need to enter into the application. The application will check this product key against your own server on start-up (or at specified intervals) and only continue if the key is valid. This way, you can control user access at all times since you can easily change product-key privileges at any point.

like image 177
Aziz Sonawalla Avatar answered Dec 01 '25 19:12

Aziz Sonawalla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!