-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
28 lines (19 loc) · 1006 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3
import hashlib
def get_registration_key(serial_number: str, key_length: int = 5) -> str:
serial_number = serial_number.upper()
trunc = 8 if len(serial_number) > 8 else len(serial_number)
mangled_serial = serial_number[:trunc] + 'W3#@8F!T' + serial_number[trunc:]
md5sum = hashlib.md5(mangled_serial.encode('utf-8')).hexdigest()
return md5sum[-key_length:].upper()
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(
description='Registration key generator for NETGEAR Smart Managed Pro switches'
)
parser.add_argument('serial_number', type=str,
help='the serial number of the device to generate the registration key for')
parser.add_argument('-l', '--length', dest='key_length', type=int, default=5,
help='the length of the registration key to return')
args = parser.parse_args()
print(get_registration_key(args.serial_number, args.key_length))