Search code examples
pythontimeepoch

is it secure to use epoch time for expiring license in python?


I inserted in my GUI python code the following lines

if time.time() > 1408492800: # 20-Aug-2014 at midnight
    disp("licence expired!")
else:
    root = Tk()
    app = App(root)
    root.mainloop()

Is that secure? Is there any other way to prevent people using the code after the 20th of august? Is any other way people could find a workaround on that?

I forgot to say that I'm going to compile than under Windows.


Solution

  • I think I found a nice workaround to my own problem using the following post adapted for Python 2.7 Get webpage contents with Python? and the webapp http://just-the-time.appspot.com/?f=%Y%m%d,%20seconds%20since%20the%20epoch:%20%t as follows

    # find the current time
    try:
        pagina = urllib.urlopen('http://just-the-time.appspot.com/?f=%Y%m%d,%20seconds%20since%20the%20epoch:%20%t')
        tempo = pagina.read()
        real_time = tempo[35:48]
    except IOError:
        exit()
    
    if (time.time() > 1408492800) or (float(real_time) > 1408492800): # 20 August 2014 at 00:00
        disp("License expired!")
    else:
        root = Tk()
        app = App(root)
        root.mainloop()