25 lines
736 B
Python
25 lines
736 B
Python
import hashlib
|
|
import argparse
|
|
|
|
# Set up command line argument parsing
|
|
parser = argparse.ArgumentParser(description="Generate EP5G password from serial.")
|
|
parser.add_argument("serial", help="Hardware serial number")
|
|
parser.add_argument("-s", "--seed", default="ANWEP5G", help="Seed value (default: ANWEP5G)")
|
|
parser.add_argument("-p", "--prefix", default="EP5G", help="Password prefix (default: EP5G)")
|
|
|
|
args = parser.parse_args()
|
|
|
|
# Combine seed and serial
|
|
seed_serial = args.seed + args.serial
|
|
|
|
# SHA-256 hash
|
|
sha_dig = hashlib.sha256(seed_serial.encode('utf-8')).hexdigest()
|
|
|
|
# Extract password portion
|
|
pointer = int(sha_dig[0], 16)
|
|
twelve = sha_dig[pointer:pointer+12]
|
|
password = f"{args.prefix}!{twelve}"
|
|
|
|
# Output
|
|
print(password)
|