Sunday, July 8, 2018

[Python 3] Licensing : Mac address, Current date, and Change in system date


import re, uuid, datetime

class cm_license():
    def __init__(self,master):
  self.master = master

# Mac address
    def macAddress():
  ma = uuid.getnode()
temp_mac = re.findall('..','%012x' % uuid.getnode())
mac = ':'.join(temp_mac)
return mac
# Check the expiry date of the license
  def checkDate():
edate = datetime.date(2018,12,30)
current = datetime.datetime.now()
cdate = datetime.date(current.year, current.month, current.day)
date_diff = edate > cdate
return date_diff


if __name__ == '__main__':
# License
license_address = '00:e1:8c:eb:87:04' # Specifiy the mac address of pc
mac_name = cm_license.macAddress()
check_date = cm_license.checkDate()
# Run the code
if (mac_name == license_address) and (check_date == True):
main()
else:
messagebox.showinfo('License','Wrong physical address')



No comments:

Post a Comment