Clean up project

loadlist() will now return a dictionary of the word list when
successfully loaded and None on failure. The unnecessary main
script was removed and core.py took it's place. Wording was
further changed from "password" to "passphrase."
This commit is contained in:
Kris Lamoureux 2016-11-09 05:53:53 -05:00
parent ab5cfd013e
commit abeffc5fc2
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
5 changed files with 48 additions and 82 deletions

View File

@ -1,7 +1,7 @@
# Dicekey
Dicekey is a [Diceware](http://diceware.com) password generator that aims to
be user friendly and encourage the adoption of strong random passwords.
Dicekey is a [Diceware](http://diceware.com) passphrase generator that aims
to be user friendly and encourage the adoption of strong random passphrases.
## Quick Start

View File

@ -1,53 +0,0 @@
# Dicekey. A Diceware password generator.
# Copyright (C) 2016 Kris Lamoureux
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Built-in
import sys
import Tkinter as tk
# Local
import diceware
class GUI:
def __init__(self, master):
frame = tk.Frame(master, padx=50, pady=50)
frame.pack()
msgtxt = "Here is a strong random passphrase for you!"
msg = tk.Label(frame, pady=15, font=("Arial", 16), text=msgtxt)
msg.pack()
pwgen = diceware.gen()
if pwgen.loadlist("dicekey/wordlist.asc"):
passwd = ' '.join(pwgen.wordgen(7))
text = tk.Label(frame, font=("FreeMono", 16), text=passwd)
text.pack()
def main():
root = tk.Tk()
root.wm_title("Dicekey Passphrase Generator")
interface = GUI(root)
root.mainloop()
sys.exit(0)
if __name__ == "dicekey.core":
main()

45
dicekey/dicekey Executable file → Normal file
View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
# Dicekey. A Diceware password generator.
# Dicekey. A Diceware passphrase generator.
# Copyright (C) 2016 Kris Lamoureux
#
# This program is free software: you can redistribute it and/or modify
@ -16,21 +16,40 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Built-in
import traceback
import sys
import Tkinter as tk
try:
import dicekey.core
# Local
from dicekey import diceware
except KeyboardInterrupt:
print "\nGoodbye!"
class App:
def __init__(self, master):
frame = tk.Frame(master, padx=50, pady=50)
frame.pack()
msgtxt = "Here is a strong random passphrase for you!"
msg = tk.Label(frame, pady=15, font=("Arial", 16), text=msgtxt)
msg.pack()
pwgen = diceware.Gen()
if pwgen.loadlist("dicekey/wordlist.asc"):
passwd = ' '.join(pwgen.wordgen(7))
text = tk.Label(frame, font=("FreeMono", 16), text=passwd)
text.pack()
def main():
root = tk.Tk()
root.wm_title("Dicekey - Passphrase Generator")
app = App(root)
root.mainloop()
sys.exit(0)
except SystemExit:
raise
except:
# Print error then wait to be closed.
traceback.print_exc()
raw_input()
sys.exit(0)
if __name__ == "__main__":
main()

View File

@ -1,4 +1,4 @@
# Dicekey. A Diceware password generator.
# Dicekey. A Diceware passphrase generator.
# Copyright (C) 2016 Kris Lamoureux
#
# This program is free software: you can redistribute it and/or modify
@ -18,21 +18,21 @@ import random
import re
class gen:
class Gen:
wordlist = {}
def __init__(self):
self.wordlist = {}
self.PRNG = random.SystemRandom()
# Generate Diceware numbers
def numgen(self, length=1):
numlist = []
PRNG = random.SystemRandom()
for _ in range(length):
number = ""
for _ in range(5):
digit = PRNG.randint(1, 6)
digit = self.PRNG.randint(1, 6)
number = number + str(digit)
numlist.append(number)
@ -55,13 +55,13 @@ class gen:
# Ensure the list is complete
if len(self.wordlist) == 7776:
return True
return self.wordlist
else:
self.wordlist = {}
return False
self.wordlist = None
return None
# Generate password
# Generate passphrase
def wordgen(self, length):
words = []

View File

@ -1,4 +1,4 @@
# Dicekey. A Diceware password generator.
# Dicekey. A Diceware passphrase generator.
# Copyright (C) 2016 Kris Lamoureux
#
# This program is free software: you can redistribute it and/or modify
@ -17,11 +17,11 @@
from distutils.core import setup
NAME = "Dicekey"
VERSION = "2.0.0-prealpha"
VERSION = "3.0.0-prealpha"
AUTHOR = "Kris Lamoureux"
AUTHOR_EMAIL = "KrisPublicEmail@gmail.com"
URL = "https://github.com/Kris619/Dicekey/"
DESCRIPTION = "A Diceware password generator"
DESCRIPTION = "A Diceware passphrase generator"
setup(
name=NAME,
@ -32,6 +32,6 @@ setup(
license="GNU GPLv3",
url=URL,
scripts = ["dicekey/dicekey"],
py_modules = ["dicekey.core", "dicekey.diceware"],
py_modules = ["dicekey.diceware"],
data_files = [("dicekey/wordlist.asc", '')]
)