Remove a few leftover lines
This commit is contained in:
parent
9f2c7c2b88
commit
0b22731076
31
keygen.py
31
keygen.py
@ -40,18 +40,14 @@ def decrypt_uploadkeys():
|
|||||||
proceed = ask_yn("Do you wish to proceed to clearing the uploadkeys file? [y/n] ")
|
proceed = ask_yn("Do you wish to proceed to clearing the uploadkeys file? [y/n] ")
|
||||||
|
|
||||||
if proceed:
|
if proceed:
|
||||||
print("Proceed1")
|
|
||||||
os.remove("uploadkeys")
|
os.remove("uploadkeys")
|
||||||
print("Removed uploadkeys file.")
|
print("Removed uploadkeys file.")
|
||||||
proceed2 = ask_yn("Would you like to continue and generate a new key? [y/n] ")
|
proceed2 = ask_yn("Would you like to continue and generate a new key? [y/n] ")
|
||||||
if not proceed2:
|
if not proceed2:
|
||||||
print("not proceed2")
|
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
print("proceed2")
|
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print("not Proceed1")
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@ -98,26 +94,15 @@ if __name__ == "__main__":
|
|||||||
print("Please run this as the correct user with: sudo su [user] -s /bin/sh -c 'python3 keygen.py'")
|
print("Please run this as the correct user with: sudo su [user] -s /bin/sh -c 'python3 keygen.py'")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Decrypt the existing keyfile
|
|
||||||
secret = load_secret()
|
|
||||||
keyf = Fernet(secret)
|
|
||||||
|
|
||||||
genkey = True
|
|
||||||
uploadkeysp = Path("uploadkeys")
|
uploadkeysp = Path("uploadkeys")
|
||||||
if not uploadkeysp.is_file():
|
if not uploadkeysp.is_file():
|
||||||
uploadkeysp.touch()
|
uploadkeysp.touch()
|
||||||
|
|
||||||
|
if decrypt_uploadkeys(): # Decrypt the file
|
||||||
|
N = 64 # Size of key
|
||||||
|
key = ''.join(secrets.choice(string.ascii_letters + string.digits) for i in range(N))
|
||||||
|
print("Your new key is: " + str(key)) # Print key
|
||||||
|
append_uploadkey(key) # Save the new key to file unencrypted
|
||||||
|
encrypt_uploadkeys() # Encrypt the uploadkeys file
|
||||||
else:
|
else:
|
||||||
with open("uploadkeys", "rb") as ukf:
|
print("Exiting.")
|
||||||
# read the encrypted data
|
|
||||||
encrypted_data = ukf.read()
|
|
||||||
|
|
||||||
|
|
||||||
if genkey:
|
|
||||||
if decrypt_uploadkeys(): # Decrypt the file
|
|
||||||
N = 64 # Size of key
|
|
||||||
key = ''.join(secrets.choice(string.ascii_letters + string.digits) for i in range(N))
|
|
||||||
print("Your new key is: " + str(key)) # Print key
|
|
||||||
append_uploadkey(key) # Save the new key to file unencrypted
|
|
||||||
encrypt_uploadkeys() # Encrypt the uploadkeys file
|
|
||||||
else:
|
|
||||||
print("Exiting.")
|
|
||||||
|
Reference in New Issue
Block a user