-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
executable file
·49 lines (36 loc) · 1.34 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
import os, sys, datetime, pyperclip
from diceware.dictreader import DictReader
from diceware.argsparser import ArgsParser
from diceware.generator import Generator
from diceware.timer import Timer
from diceware.logger import Logger
from diceware.argsparser import ArgsParser
def log(logger, datetime, passphrase):
logger.write(datetime, passphrase)
def init():
argsparser = ArgsParser(sys.argv)
options = argsparser.get_generator_options()
reader = DictReader(options)
timer = Timer()
timer.start()
gen = Generator(options, reader)
passphrase = gen.generate_passphrase()
pyperclip.copy(passphrase) # Copy the passphrase to the users clipboard
print('''
____ _
/ __ \(_)_______ _ ______ _________
/ / / / / ___/ _ \ | /| / / __ `/ ___/ _ \\
/ /_/ / / /__/ __/ |/ |/ / /_/ / / / __/
/_____/_/\___/\___/|__/|__/\__,_/_/ \___/
''')
print("Started generating at: " + str(timer.start))
print(timer.stop())
print(timer.elapsed())
print("\nPassphrase: " + str(passphrase))
print("The passphrase is copied to your clipboard, press CTRL + V to paste")
if (options.get("-log")):
logger = Logger()
log(logger, datetime.datetime.now(), passphrase)
if (__name__ == "__main__"):
init() # Initialise