Completed challenge 121
This commit is contained in:
parent
714ed01a80
commit
e5e90e0542
@ -72,9 +72,10 @@ Menu:\n\
|
||||
(a) Estimate Astral Projection Mana Burn\n\
|
||||
(b) [LOCKED] Estimate Astral Slingshot Approach Vector\n\
|
||||
(c) Enter License Key\n\
|
||||
(d) Exit Arcane Calculator")
|
||||
(d) Exit Arcane Calculator\n\
|
||||
(e) Generate License Key")
|
||||
|
||||
choice = input("What would you like to do, "+ username_trial +" (a/b/c/d)? ")
|
||||
choice = input("What would you like to do, "+ username_trial +" (a/b/c/d/e)? ")
|
||||
|
||||
if not validate_choice(choice):
|
||||
print("\n\nInvalid choice!\n\n")
|
||||
@ -90,6 +91,10 @@ Menu:\n\
|
||||
global arcane_loop_trial
|
||||
arcane_loop_trial = False
|
||||
print("Bye!")
|
||||
elif choice == "e":
|
||||
global bUsername_trial
|
||||
key = generate_license_key(bUsername_trial)
|
||||
print(f'License key for {bUsername_trial}: {key}')
|
||||
else:
|
||||
print("That choice is not valid. Please enter a single, valid \
|
||||
lowercase letter choice (a/b/c/d).")
|
||||
@ -99,7 +104,8 @@ def validate_choice(menu_choice):
|
||||
if menu_choice == "a" or \
|
||||
menu_choice == "b" or \
|
||||
menu_choice == "c" or \
|
||||
menu_choice == "d":
|
||||
menu_choice == "d" or \
|
||||
menu_choice == "e":
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@ -137,6 +143,13 @@ def enter_license():
|
||||
print("\nKey is NOT VALID. Check your data entry.\n\n")
|
||||
|
||||
|
||||
def generate_license_key(username_trial):
|
||||
hex_digest = hashlib.sha256(username_trial).hexdigest()
|
||||
dynamic_part = ''.join(hex_digest[i] for i in [4,5,3,6,2,7,1,8])
|
||||
global key_part_static1_trial
|
||||
global key_part_static2_trial
|
||||
return f'{key_part_static1_trial}{dynamic_part}{key_part_static2_trial}'
|
||||
|
||||
def check_key(key, username_trial):
|
||||
|
||||
global key_full_template_trial
|
||||
|
Loading…
x
Reference in New Issue
Block a user