Git Product home page Git Product logo

python-password-generator's Introduction

Python-password-generator (PyPass)

Module for quick generation of passwords with Python.

Passwords are generated by randomly choosing characters from designated sets using the secrets module, with the option to implement various rules and restrictions (length, exclusion/inclusion of characters, words or phrases, removing consecuitve duplicate chars etc.).

All generated passwords are checked against lists of breached passwords (from https://haveibeenpwned.com/) using the pyhibp module.

Usages:

  1. In scripts: use PyPass class to instantiate password generator objects. Use parameters from settings.py, or pass custom parameters to each instance. Generates passwords by:

    i) using generate_human_password(), a function designed to generate passwords using certain rules and limitations commonly advised when generating passwords for various user accounts; OR

    ii) using the generate_password(), a function which allows the user to generate passwords implementing fully customizable set of rules.

  2. From terminal, by passing 'python3 pypass.py [parameters]' according to the following instructions:

    --password_number NUMBER_OF_PASSWORDS, -pn NUMBER_OF_PASSWORDS

     		Number of passwords to be generated.
    

    --min_len MIN_PASS_LEN, -min MIN_PASS_LEN

     		Minimum password length.
    

    --max_len MAX_PASS_LEN, -max MAX_PASS_LEN

     		Maximum password length.
    

    --fix_len FIX_PASS_LEN, -fix FIX_PASS_LEN

     		Enforces constant length of passwords.
    

    --usable_chars USER_USABLE_CHARS, -uc USER_USABLE_CHARS

     		A list of characters to be used in password
     		generation.Can be separated into multiple lists
     		('[1,2,3],['a','b','c'],[')','_','=']'),in which case
     		this will, among other things, influence maintaining
     		proportions. Using nested lists will cause errors.If
     		not defined, USABLE_CHARS from settings.py will be
     		used.
    

    --excluded_chars USER_EXCLUDED_CHARS, -ec USER_EXCLUDED_CHARS

     		A list of characters that CANNOT be used in password
     		generation.Any character listed here will be removed
     		from list(s) of usable characters. If not defined,
     		EXCLUDED_CHARS from settings.py will be used.
    

    --excluded_words USER_EXCLUDED_WORDS, -ew USER_EXCLUDED_WORDS

     		A list of words or other sequences of characters that
     		can't be contained in the password.Any item from the
     		list will, if found, be removed from the password and
     		replace with a random sequence of character from the
     		usable_char list(s). If not defined, EXCLUDED_WORDS
     		from settings.py will be used.
    

    --remove_english REMOVE_ENGLISH, -re REMOVE_ENGLISH

     		If not False, will cause English words to be removed
     		from the passwords.
    

    --remove_repeating REMOVE_REPEATING, -rr REMOVE_REPEATING

     		If not False, will cause touching duplicate characters
     		to be removed from the passwords.
    

    --ensure_proportions ENSURE_PROPORTIONS, -ep ENSURE_PROPORTIONS

     		If not False, the password will contain at least one
     		character from each list in usable_chars.
    

    --human, -hu Module will use generate_human_password() instead of generate_password(). Only settings usable with this function will be applied.

    --simple, -sm Activates 'simple' mode. User will be able to change parameters for password length and use simple commands to eliminate predefined character groups (numbers, lowercase, uppercase and punctuation) from usable_chars. Password will be generated using generate_password() function.

    --digi, -dt Reserved for Simple Mode. Removes digits from usable_chars.

    --lower, -l Reserved for Simple Mode. Removes lower case letters from usable_chars.

    --upper, -up Reserved for Simple Mode. Removes upper case letters from usable_chars.

    --punct, -pu Reserved for Simple Mode. Removes punctuation from usable_chars.

    --remove_quote, -rq Reserved for Simple Mode. Removes single quote << ' >> from usable_chars.

  3. Calling pypass.py from a bash script, e.g.:

    i) [path to python] [path to pypass.py] *$ --> allows passing all positional arguments to pypass.py from terminal,

    OR

    ii) [path to python] [path to pypass.py] [user designated positional arguments] --> generate passwords according to parameters previously set by the user.

Requires Python 3.6+

Tests in test_password.py

Important: In case of issues with running nltk.core.wordnet, consult: 'http://www.velvetcache.org/2010/03/01/looking-up-words-in-a-dictionary-using-python'

Many thanks to everyone who posted in https://www.reddit.com/r/learnpython/comments/arjq9l/password_generator_in_python/, every criticism was invaluable (all mistakes made in the code are exclusively author's).

python-password-generator's People

Contributors

blucyblue avatar aareon avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.