python的License授权机制
1.生成license文件
license_utils.py
# -*- coding: UTF-8 -*-
import re
import sys
import datetime
import subprocess
from Crypto.Cipher import AES
from binascii import a2b_hex
from binascii import b2a_hex
class get_license_file():
def __init__(self, mac, date):
self.mac = mac
self.date = date
def encrypt(self, content):
# content length must be a multiple of 16.
while len(content) % 16:
content += ' '
content = content.encode('utf-8')
# Encrypt content.
aes = AES.new(b'2021052020210520', AES.MODE_CBC, b'2021052020210520')
encrypted_content = aes.encrypt(content