Skip to content

Commit

Permalink
Make passphraseme a python module that includes wordlists as package …
Browse files Browse the repository at this point in the history
…data
  • Loading branch information
micahflee committed Sep 27, 2018
1 parent ff5af21 commit 6d1375b
Show file tree
Hide file tree
Showing 8 changed files with 10,557 additions and 1,225 deletions.
111 changes: 111 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PassphraseMe

A quick and simple cryptographically secure script to generate high entropy passphrases using [the Electronic Frontier Foundation's word list](https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases).
A quick and simple cryptographically secure script to generate high entropy passphrases using [the Electronic Frontier Foundation's wordlists](https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases).

## Usage

Expand Down
1,224 changes: 0 additions & 1,224 deletions passphraseme

This file was deleted.

42 changes: 42 additions & 0 deletions passphraseme/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import sys
import os
import inspect
from secrets import choice


def generate(filename, word_count=7):
try:
with open(filename) as f:
words = [line.rstrip('\n') for line in f]
except FileNotFoundError:
print("The wordlist filename doesn't exist.")
sys.exit()

return ' '.join(choice(words) for _ in range(word_count))


def main():
parser = argparse.ArgumentParser()
parser.add_argument('word_count', metavar='word_count', default=7, help='Word count')
parser.add_argument('-d', '--dictionary', nargs='?', metavar='dictionary', help='Dictionary file')
args = parser.parse_args()

if args.dictionary is not None:
filename = args.dictionary
else:
wordlists_path = os.path.join(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))), 'wordlists')
filename = os.path.join(wordlists_path, 'eff_large_wordlist.txt')

if not args.word_count.isdigit():
print("Please input a valid number.")
sys.exit()

passphrase = generate(filename, int(args.word_count))
print(passphrase)


if __name__ == '__main__':
main()
Loading

0 comments on commit 6d1375b

Please sign in to comment.