Skip to content

Commit b28576d

Browse files
committed
feat: license key in file implemented
1 parent bcb8060 commit b28576d

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.vscode/settings.json
2-
env/
2+
env/
3+
license.lic
4+
machine.lic

main.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,32 @@ def get_serial_number():
4747
serial_number = str(serial_number)
4848
hash_serial = hashlib.sha3_512(serial_number.encode())
4949
parser = argparse.ArgumentParser()
50-
parser.add_argument('-p', '--path', dest='path', default="./machine.lic", help='Path to machine file')
51-
parser.add_argument('-l', '--license', dest='license',
52-
default='key/TEg3TS05VldLLUpKSFUtN0NSVC1NUEtSLUg5VUwtOU1GNy03VjlK'
53-
'.hphP_9YaFq0uZykkfH0l9xEmogJ4yUbo3Wym7oIxYgl0uNBwocsS3GZse6U2Ti2a8B09iB5'
54-
'-gi_ilr3V05z4Dw==',
55-
help='License key')
50+
parser.add_argument('-p', '--path-machine', dest='path_machine', default="./machine.lic", help='Path to machine '
51+
'file')
52+
parser.add_argument('-l', '--path-license', dest='path_license', default='./license.lic', help='Path to license '
53+
'key file')
5654
parser.add_argument('-f', '--fingerprint', dest='fingerprint', default=hash_serial.hexdigest(),
5755
help='Machine fingerprint')
5856
KEYGEN_PUBLIC_KEY = '7757a98a8188c31ae7a21d76a865800bf77bcf3476f7abbbdf5bb6a4afbe9a23'
5957
args = parser.parse_args()
6058
machine_file = None
59+
license_file = None
60+
61+
# Read the license key file
62+
try:
63+
with open(args.path_license) as f_license:
64+
license_key = f_license.read()
65+
except (FileNotFoundError, PermissionError):
66+
print('[error] license path does not exist! (or permission was denied)')
67+
68+
sys.exit(1)
6169

6270
# Read the machine file
6371
try:
64-
with open(args.path) as f:
65-
machine_file = f.read()
72+
with open(args.path_machine) as f_machine:
73+
machine_file = f_machine.read()
6674
except (FileNotFoundError, PermissionError):
67-
print('[error] path does not exist! (or permission was denied)')
75+
print('[error] machine path does not exist! (or permission was denied)')
6876

6977
sys.exit(1)
7078

@@ -105,7 +113,7 @@ def get_serial_number():
105113

106114
# Hash the license key and fingerprint using SHA256
107115
digest = hashes.Hash(hashes.SHA256())
108-
digest.update(args.license.encode())
116+
digest.update(license_key.encode())
109117
digest.update(args.fingerprint.encode())
110118
key = digest.finalize()
111119

0 commit comments

Comments
 (0)