From f3a116d11fd04e7c72bb5d3382ced0850dd9994d Mon Sep 17 00:00:00 2001 From: root Date: Sat, 13 May 2023 21:36:32 +0200 Subject: [PATCH] added seed output --- InstallDepLinux.sh | 0 true_random_seed_pw_gen.py | 26 ++++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) mode change 100644 => 100755 InstallDepLinux.sh diff --git a/InstallDepLinux.sh b/InstallDepLinux.sh old mode 100644 new mode 100755 diff --git a/true_random_seed_pw_gen.py b/true_random_seed_pw_gen.py index 8900e74..c9752e8 100644 --- a/true_random_seed_pw_gen.py +++ b/true_random_seed_pw_gen.py @@ -11,6 +11,7 @@ parser = argparse.ArgumentParser(prog='True Random Password Generator', descript parser.add_argument('-a', '--apikey', default=os.environ['HOME']+'/.bin/.apikey' , type=str, help='path to a file which contains only a random.org api key') parser.add_argument('-c', '--count', default='50', type=int, help='the number of passwords to generate') parser.add_argument('-l', '--length', default='20', type=int, help='the length the generated passwords should have') +parser.add_argument('-s', '--seed', action='store_true', help='outputs the queried seed instead of initialzing the pseudo random vector') args = parser.parse_args() @@ -44,18 +45,19 @@ with suppress_std_err_out(): seed=response["random"]["data"] #Filling the seed with a (true) random number -characters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#_@!?+" -char_lst = [x for x in characters] -random.seed(int(seed[0])) -#Building password -for _ in range(0,args.count): - pw_string="" - for _ in range(0,args.length): - pw_string += char_lst[random.randint(0, 67)] - print(pw_string) - - - +if not args.seed: + characters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#_@!?+" + char_lst = [x for x in characters] + random.seed(int(seed[0])) + #Building password + for _ in range(0,args.count): + pw_string="" + for _ in range(0,args.length): + pw_string += char_lst[random.randint(0, 67)] + print(pw_string) +else: + print("-------------------------------------------") + print('Seed: '+str(seed[0])); print("-------------------------------------------") bit_uses_left=response["bitsLeft"] // response["bitsUsed"]