How to use the xkcdpass.xkcd_password function in xkcdpass

To help you get started, we’ve selected a few xkcdpass examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github redacted / XKCD-password-generator / tests / test_xkcdpass.py View on Github external
def setUp(self):
        """ Set up fixtures for this test case. """
        self.wordlist_small = xkcd_password.generate_wordlist(
            wordfile='tests/test_list.txt',
            valid_chars='[a-z]')

        self.options = argparse.Namespace(
            interactive=False,
            numwords=6,
            count=1,
            acrostic=False,
            delimiter=" ",
            separator=u"\n",
            case='lower',
        )

        self.stdout_patcher = mock.patch.object(
            sys, 'stdout', new_callable=io.StringIO)
github BrynMawrCollege / jupyterhub / accounts.py View on Github external
argv = arg_string.split()
    parser = xkcd_password.XkcdPassArgumentParser(prog="xkcdpass")

    options = parser.parse_args(argv)
    xkcd_password.validate_options(parser, options)

    my_wordlist = xkcd_password.generate_wordlist(
        wordfile=options.wordfile,
        min_length=options.min_length,
        max_length=options.max_length,
        valid_chars=options.valid_chars)

    if options.verbose:
        xkcd_password.verbose_reports(my_wordlist, options)

    return xkcd_password.generate_xkcdpassword(
        my_wordlist,
        interactive=options.interactive,
        numwords=options.numwords,
        acrostic=options.acrostic,
        delimiter=options.delimiter)
github bwaldvogel / openmoves / create_user.py View on Github external
def create_user(app, username, password=None):
    with app.app_context():
        wordfile = xp.locate_wordfile()
        mywords = xp.generate_wordlist(wordfile=wordfile, min_length=5, max_length=8)
        if not password:
            print("generated password: '%s'" % password)
            password = xp.generate_xkcdpassword(mywords, acrostic="ambit")

        assert not User.query.filter_by(username=username).scalar(), "user already exists"

        user = User(username=username)
        user.password = app_bcrypt.generate_password_hash(password, 10)
        user.active = True
        db.session.add(user)
        db.session.commit()

        print("created user '%s'" % user.username)
github SHSIDers / oclubs / oclubs / objs / user.py View on Github external
def generate_password():
        return xp.generate_xkcdpassword(_words)
github MechWolf / MechWolf / mechwolf / security_key_tools.py View on Github external
def generate_security_key():
    '''Generates a human-friendly cryptographically secure security keys.

    Returns:
        str: A security key consisting of six words delimited by dashes

    Example:
        >>> mw.generate_security_key()
        'epilogue-stilt-crux-task-corset-carton'
    '''
    wordfile = xp.locate_wordfile()
    word_list = xp.generate_wordlist(wordfile=wordfile, min_length=0, max_length=10)
    while True:
        key = xp.generate_xkcdpassword(word_list, delimiter="-")
        if validate_security_key(key): # ensure key is valid
            return key
github redacted / XKCD-password-generator / examples / example_json.py View on Github external
def json_password_generator(request):
    # Example Django view to generate passphrase suggestions via xkcd library
    # Called with optional params e.g.
    # /json_password_generator/?tc=true&separator=|&acrostic=face

    if request.method == 'GET':
        acrostic = request.GET.get("acrostic", None)
        titlecase = request.GET.get("tc", None)

        wordfile = xp.locate_wordfile()
        words = xp.generate_wordlist(
            wordfile=wordfile,
            min_length=3,
            max_length=8)
        suggestion = xp.generate_xkcdpassword(words, acrostic=acrostic)

        if titlecase:
            # Convert "foo bar" to "Foo Bar"
            suggestion = suggestion.title()

        return JsonResponse({
            'suggestion': suggestion}
            )