add path argument for secret
This commit is contained in:
parent
bded598a6e
commit
f0e613919a
9
raps.py
Normal file → Executable file
9
raps.py
Normal file → Executable file
@ -30,15 +30,18 @@ def generate_seed(secret):
|
||||
def main():
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(prog='Remote Admin Password Solution', description='Generate rotating passwords based on a shared secret')
|
||||
parser.add_argument('--secret', action='store', help='path to secret file')
|
||||
parser.add_argument('--new-secret', action='store_true', help='generate a new secret')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
secret_path = args.secret if args.secret else SECRET_FILE
|
||||
|
||||
secret = ''
|
||||
if not os.path.isfile(SECRET_FILE) or args.new_secret:
|
||||
if not os.path.isfile(secret_path) or args.new_secret:
|
||||
print('Generating a new secret... ', end='')
|
||||
secret = create_secret()
|
||||
with open(SECRET_FILE, 'w') as f:
|
||||
with open(secret_path, 'w') as f:
|
||||
f.write(secret)
|
||||
print('done. Send this to the other party:')
|
||||
print(secret)
|
||||
@ -48,7 +51,7 @@ def main():
|
||||
print('Secret loaded.')
|
||||
|
||||
random.seed(generate_seed(secret))
|
||||
|
||||
|
||||
print('The password of the month is:')
|
||||
print(generate_password())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user