def generate_strong_pwd():
    # 3 words, random CAPITALIZATION, random number as separator between words
    words = xp.generate_xkcdpassword(wordlist=wordlist, numwords=3, delimiter=" ").split()
    return "{word0}{randnum0}{word1}{randnum1}{word2}".format(word0=str.upper(words[0]) if throw_random() else words[0],
                                                              word1=str.upper(words[1]) if throw_random() else words[1],
                                                              word2=str.upper(words[2]) if throw_random() else words[2],
                                                              randnum0=random.randint(0, 9),
                                                              randnum1=random.randint(0, 9))
def generate_insane_pwd():
    # 4 words, second one CAPITALIZED, separators, prefixes and suffixes
    words = xp.generate_xkcdpassword(wordlist=wordlist, numwords=4, delimiter=" ").split()
    return "{randsymbol}{randsymbol}{word0}{separator}{word1}{separator}{word2}{randsymbol}{randsymbol}" \
        .format(randsymbol=random.choice("!$%^&*-_+=:|~?/.;0123456789"),
                word0=words[0],
                word1=str.upper(words[1]),
                word2=words[2],
                separator=random.choice(".$*;_=:|~?!%-+"))
Example #3
0
def generate_stronger_pwd():
    # Same as "strong", but using 4 words
    words = xp.generate_xkcdpassword(wordlist=wordlist, numwords=4, delimiter=" ").split()
    return "{word0}{randnum0}{word1}{randnum1}{word2}{randnum2}{word3}" \
        .format(word0=str.upper(words[0]) if throw_random() else words[0],
                word1=str.upper(words[1]) if throw_random() else words[1],
                word2=str.upper(words[2]) if throw_random() else words[2],
                word3=str.upper(words[3]) if throw_random() else words[3],
                randnum0=random.randint(0, 9),
                randnum1=random.randint(0, 9),
                randnum2=random.randint(0, 9))
def generate_stronger_pwd():
    # Same as "strong", but using 4 words
    words = xp.generate_xkcdpassword(wordlist=wordlist, numwords=4, delimiter=" ").split()
    return "{word0}{randnum0}{word1}{randnum1}{word2}{randnum2}{word3}" \
        .format(word0=str.upper(words[0]) if throw_random() else words[0],
                word1=str.upper(words[1]) if throw_random() else words[1],
                word2=str.upper(words[2]) if throw_random() else words[2],
                word3=str.upper(words[3]) if throw_random() else words[3],
                randnum0=random.randint(0, 9),
                randnum1=random.randint(0, 9),
                randnum2=random.randint(0, 9))
def generate_insane_pwd():
    # 4 words, second one CAPITALIZED, separators, prefixes and suffixes
    words = xp.generate_xkcdpassword(wordlist=wordlist,
                                     numwords=4,
                                     delimiter=" ").split()
    return "{randsymbol}{randsymbol}{word0}{separator}{word1}{separator}{word2}{randsymbol}{randsymbol}" \
        .format(randsymbol=random.choice("!$%^&*-_+=:|~?/.;0123456789"),
                word0=words[0],
                word1=str.upper(words[1]),
                word2=words[2],
                separator=random.choice(".$*;_=:|~?!%-+"))
def generate_strong_pwd():
    # 3 words, random CAPITALIZATION, random number as separator between words
    words = xp.generate_xkcdpassword(wordlist=wordlist,
                                     numwords=3,
                                     delimiter=" ").split()
    return "{word0}{randnum0}{word1}{randnum1}{word2}".format(
        word0=str.upper(words[0]) if throw_random() else words[0],
        word1=str.upper(words[1]) if throw_random() else words[1],
        word2=str.upper(words[2]) if throw_random() else words[2],
        randnum0=random.randint(0, 9),
        randnum1=random.randint(0, 9))
Example #7
0
def yield_words(wordlist, options):
    """Yield the specified number of passwords."""
    count = options.count
    while count > 0:
        yield xp.generate_xkcdpassword(wordlist,
                                       interactive=options.interactive,
                                       numwords=options.numwords,
                                       acrostic=options.acrostic,
                                       delimiter=options.delimiter).split(
                                           options.delimiter)
        count -= 1
Example #8
0
    def suggest_password(cls):
        from xkcdpass import xkcd_password as xp

        xp_wordfile = xp.locate_wordfile()
        xp_wordlist = xp.generate_wordlist(
            wordfile=xp_wordfile, min_length=4, max_length=6, valid_chars='[a-z]'
        )
        suggested_password = xp.generate_xkcdpassword(
            xp_wordlist, numwords=4, acrostic='wild', delimiter=' '
        )
        return suggested_password
Example #9
0
def passphrase_generator(len=12):
    """
    Generates a random passphrase
    :param len:
    :return:
    """
    from xkcdpass import xkcd_password as xp
    wordfile = xp.locate_wordfile()
    mywords = xp.generate_wordlist(wordfile=wordfile,
                                   min_length=5,
                                   max_length=8)
    return xp.generate_xkcdpassword(mywords, numwords=len)
    def __init__(self, user):
        '''Create a new InitialToken instance

        '''
        if isinstance(user, User):
            user = user.id

        self.user_id = user
        self.token = xkcd_password.generate_xkcdpassword(
            short_token_wordlist,
            numwords=2
        ).decode('utf-8')
Example #11
0
def _generate_passwd(length=4):
    """
    Create an XKCD style (correct-horse-battery-staple) password.

    Keyword arguments:
    length -- Number of words to have in password
    """
    wordfile = xp.locate_wordfile()
    mywords = xp.generate_wordlist(wordfile=wordfile,
                                   min_length=5,
                                   max_length=8)
    return xp.generate_xkcdpassword(mywords, delimiter="-", numwords=length)
def generate_insane_pwd():
    # 4 words, second one CAPITALIZED, separators, prefixes and suffixes
    words = xkcd_password.generate_xkcdpassword(wordlist=app_config.words,
                                                numwords=4,
                                                delimiter=" ").split()
    return "{prefix}{word0}{separator1}{word1}{separator2}{word2}{suffix}" \
        .format(prefix=random.choice("!$%^&*-_+=:|~?/.;0123456789"),
                suffix=random.choice("!$%^&*-_+=:|~?/.;0123456789"),
                word0=words[0],
                word1=str.upper(words[1]),
                word2=words[2],
                separator1=random.choice(".$*;_=:|~?!%-+"),
                separator2=random.choice(".$*;_=:|~?!%-+"))
Example #13
0
def generate_password(unique=False):
    """Generate an XKCD style password"""
    # create a wordlist from the default wordfile
    # use words between 5 and 8 letters long
    wordfile = xp.locate_wordfile()
    mywords = xp.generate_wordlist(wordfile=wordfile,
                                   min_length=5,
                                   max_length=8)
    # Chose a random four-letter word for acrostic
    acword = random.choice(  # nosec
        xp.generate_wordlist(wordfile=wordfile, min_length=4, max_length=4))
    # create a password with acrostic word
    pword = xp.generate_xkcdpassword(mywords, acrostic=acword)
    return pword
Example #14
0
def generate_password(length=4, delimiter="-", easy_mode=False):
    """returns a xkcd-style password"""
    if easy_mode == True:
        return generate_easy_password()
    wordfile = xp.locate_wordfile("ger-anlx")
    mywords = xp.generate_wordlist(wordfile=wordfile,
                                   min_length=3,
                                   max_length=16,
                                   valid_chars="[a-z]")
    password = xp.generate_xkcdpassword(mywords,
                                        numwords=length,
                                        delimiter=delimiter,
                                        case="capitalize")
    return password
Example #15
0
    def generate_password(self):
        def capitalize_first_letter(s):
            new_str = []
            s = s.split(" ")
            for i, c in enumerate(s):
                new_str.append(c.capitalize())
            return "".join(new_str)

        words = xp.locate_wordfile()
        mywords = xp.generate_wordlist(wordfile=words,
                                       min_length=5,
                                       max_length=8)
        raw_password = xp.generate_xkcdpassword(mywords)

        return capitalize_first_letter(raw_password)
Example #16
0
    def handle_creator_password(self, message):
        number_of_words = message.data.get("NumberOfWords")
        number_of_words = extract_number(
            number_of_words) if number_of_words else 6

        acrostic = message.data.get("Acrostic")
        acrostic = acrostic if acrostic else False

        wordfile = xp.locate_wordfile()
        words = xp.generate_wordlist(wordfile=wordfile)  # Can modify
        password = xp.generate_xkcdpassword(words,
                                            number_of_words,
                                            acrostic=acrostic)  # Can modify

        self.speak_dialog('creator.password', data={'password': password})
Example #17
0
    async def start_quiz(self, data: Dict):
        print("Quiz registration was called")
        game_name = data["game_name"]
        participants = data["players"]
        participants_list = []
        con = await self.pool.acquire()
        cur = await con.cursor()

        await cur.execute("SELECT id from roles WHERE name=%s",
                          ("mobile-client", ))
        user_role_id = await cur.fetchone()
        user_role_id = user_role_id[0]
        game_id = await self.get_tag_id(game_name)
        time_stmp = datetime.datetime.now()
        try:
            await cur.execute("INSERT INTO games VALUES(%s, %s)",
                              (game_id, time_stmp))
        except Exception:
            print("Warning! Game was initiated before")
        finally:
            full_game_name = "com." + game_name
            wordfile = xp.locate_wordfile()
            mywords = xp.generate_wordlist(wordfile=wordfile,
                                           min_length=5,
                                           max_length=5)
            for user_name in participants:
                secret = xp.generate_xkcdpassword(mywords,
                                                  acrostic="hi",
                                                  delimiter=":")
                # secret = string.capwords(secret)
                await cur.execute(
                    "INSERT INTO users(name, secret, role_id) VALUES(%s, %s, %s) RETURNING id",
                    (user_name, secret, user_role_id))
                # self.cur.execute("SELECT last_insert_rowid()")
                cur_user_id = await cur.fetchone()
                cur_user_id = cur_user_id[0]
                participants_list.append(cur_user_id)
                await cur.execute("INSERT INTO user_game VALUES(%s, %s)",
                                  (cur_user_id, game_id))
            cur_game = await self.subscribe(
                lambda question: self.on_question_posted(game_name, question),
                full_game_name + ".questions")
            self.games[game_name] = Dbase.Game(cur_game, game_id)
            self.games[game_name].participants_list = participants_list
            print("subscribed")
            print(self.pool.freesize)
            await self.pool.release(con)
            return True
Example #18
0
    def run(self, username, password=None):
        with self.app_context():
            if not password:
                wordfile = xp.locate_wordfile()
                mywords = xp.generate_wordlist(wordfile=wordfile, min_length=5, max_length=8)
                password = xp.generate_xkcdpassword(mywords, acrostic="ambit")
                print("generated password: '******'" % password)

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

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

            print("created user '%s' in '%s'" % (user.username, db.engine.url))
def generate_custom(user):
    user = dbworker.get_person(user)
    words = [str.upper(word) if throw_random() else word for word in xp.generate_xkcdpassword(
        wordlist=wordlist, numwords=user["word_count"], delimiter=" ").split()
             ]
    # Generate password without prefixes & suffixes
    _pwd = random.choice(".$*;_=:|~?!%-+").join(words) if user["separators"] else "".join(words)

    # Add prefixes/suffixes (if needed)
    if user["prefixes"]:
        password = "******".format(
            prefix=random.choice("!$%^&*-_+=:|~?/.;0123456789"),
            password=_pwd
        )
    else:
        password = _pwd
    return password
Example #20
0
    def run(self, username, password=None):
        with self.app_context():
            if not password:
                wordfile = xp.locate_wordfile()
                mywords = xp.generate_wordlist(wordfile=wordfile, min_length=5, max_length=8)
                password = xp.generate_xkcdpassword(mywords, acrostic="ambit")
                print("generated password: '******'" % password)

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

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

            print("created user '%s' in '%s'" % (user.username, db.engine.url))
Example #21
0
def create_ethereum_account():
    ac = Account.create()
    wf = xp.locate_wordfile()
    words = xp.generate_wordlist(wordfile=wf, min_length=5, max_length=8)

    password_str = xp.generate_xkcdpassword(words)
    print(
        cyan(
            "password string to decrypt private key -- please store in safe location:"
        ))
    print()
    print(yellow(password_str))
    print()
    print(cyan("address:"))
    print(yellow(ac.address))

    ks = json.dumps(Account.encrypt(ac.privateKey, password_str), indent=2)
    print(red(ks))
Example #22
0
def random_password(user_id):
    """Sends a new password after generating it."""
    try:
        user = User.objects.get(id=user_id)
        wordfile = xp.locate_wordfile()
        mywords = xp.generate_wordlist(wordfile=wordfile,
                                       min_length=5,
                                       max_length=10)
        password = xp.generate_xkcdpassword(mywords)
        user.password = password
        user.save()
        msg = create_message('Your new password', user.email)
        context = {'user': user.to_dict(), 'password': password}
        msg.body = render_template('emails/pass.txt', **context)
        mail.send(msg)
    except (db.DoesNotExist):
        app.logger.warning(
            'Attempted to send new password to non existing user.')
def generate_custom(user):
    user = dbworker.get_person(user)
    words = [
        str.upper(word) if throw_random() else word
        for word in xp.generate_xkcdpassword(wordlist=wordlist,
                                             numwords=user["word_count"],
                                             delimiter=" ").split()
    ]
    # Generate password without prefixes & suffixes
    _pwd = random.choice(".$*;_=:|~?!%-+").join(
        words) if user["separators"] else "".join(words)

    # Add prefixes/suffixes (if needed)
    if user["prefixes"]:
        password = "******".format(
            prefix=random.choice("!$%^&*-_+=:|~?/.;0123456789"), password=_pwd)
    else:
        password = _pwd
    return password
Example #24
0
def initialize():
    # Initialize settings
    # Initialize Dashboard connection
    dashboard = meraki.DashboardAPI(
        caller="PSKRotator/1.0 Kuchta Meraki"
    )

    # Get the networks list
    networks_list = dashboard.organizations.getOrganizationNetworks(
        organizationId=ORGANIZATION_ID
    )

    # PASSPHRASE/PSK GENERATION
    # Password generator configuration
    password_word_list = xp.generate_wordlist(min_length=MINIMUM_LENGTH, max_length=MAXIMUM_LENGTH)

    # Generate today's PSK
    new_psk = xp.generate_xkcdpassword(password_word_list, numwords=NUMBER_OF_WORDS)

    return dashboard, networks_list, new_psk
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}
            )
Example #26
0
def create_invitation(user: User,
                      primary_user_group: UserGroup = None) -> UserInvitation:
    """
    Create an invitation string for a new user. The user_id most correspond to an admin user
    :param user:
    :param primary_user_group:
    :return:
    """
    if user.admin:
        invite_string = xp.generate_xkcdpassword(
            xp.generate_wordlist(valid_chars='[a-z]'),
            numwords=3,
            delimiter='_')
        invitation = UserInvitation(creator=user,
                                    primary_user_group=primary_user_group,
                                    value=invite_string)
        db.session.add(invitation)
        db.session.commit()
        return invitation
    raise AuthException(
        f'User {user.email} is not an administrator and cannot view or edit invitations.'
    )
Example #27
0
    def generate(self):
        '''add new port/password to the system.'''

        ###############################################################################
        # 1. generate the new port
        ###############################################################################

        #current_ports = self.used_ports()
        current_ports = set([])

        possible_ports = set(
            range(self.MIN_PORT_NUMBER,
                  self.MAX_PORT_NUMBER + 1)) - current_ports

        if not possible_ports:
            raise ValueError("Didn't have any ports to choose from!")

        # could also do
        ## new_port = possible_ports.pop()
        # but I was concerned that would make the port number too predictable
        new_port = int(random.choice(list(possible_ports)))

        ###############################################################################
        # 2. generate the new password
        ###############################################################################
        new_password = xp.generate_xkcdpassword(
            self.xkcd_wordlist,
            numwords=self.PASSWORD_NUMBER_OF_WORDS,
            delimiter='-')

        # send these to the server
        the_str = 'add: {"server_port": %d, "password":"******"}' % (new_port,
                                                                 new_password)
        self.sock.send(bytes(the_str, 'utf-8'))

        # add this to the use ports list
        self.ports_in_use.add(int(new_port))

        return new_port, str(new_password)
Example #28
0
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}
            )
Example #29
0
def make_password(arg_string=None):
    if arg_string is None:
        arg_string = "-w safe6 -n 4 --min 1 --max=6"
    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)
Example #30
0
def create_audit_boards(election: Election, jurisdiction: Jurisdiction,
                        round_id: str):
    json_audit_boards = request.get_json()
    round = Round.query.get_or_404(round_id)
    validate_audit_boards(json_audit_boards, election, jurisdiction, round)

    audit_boards = [
        AuditBoard(
            id=str(uuid.uuid4()),
            name=json_audit_board["name"],
            jurisdiction_id=jurisdiction.id,
            round_id=round.id,
            passphrase=xp.generate_xkcdpassword(WORDS,
                                                numwords=4,
                                                delimiter="-"),
        ) for json_audit_board in json_audit_boards
    ]
    db.session.add_all(audit_boards)

    assign_sampled_ballots(jurisdiction, round, audit_boards)

    db.session.commit()

    return jsonify(status="ok")
import random

import xkcdpass.xkcd_password as xp


def random_capitalisation(s, chance):
    new_str = []
    for i, c in enumerate(s):
        new_str.append(c.upper() if random.random() < chance else c)
    return "".join(new_str)

def capitalize_first_letter(s):
    new_str = []
    s = s.split(" ")
    for i, c in enumerate(s):
        new_str.append(c.capitalize())
    return "".join(new_str)


words = xp.locate_wordfile()
mywords = xp.generate_wordlist(wordfile=words, min_length=5, max_length=8)
raw_password = xp.generate_xkcdpassword(mywords)

for i in range(5):
    print(random_capitalisation(raw_password, i/10.0))

print(capitalize_first_letter(raw_password))
Example #32
0
def generate_password():
    from xkcdpass import xkcd_password as xp
    mywords = xp.generate_wordlist()
    return xp.generate_xkcdpassword(mywords, numwords=4)
def generate_weak_pwd():
    # 2 words, no separators between words
    return xp.generate_xkcdpassword(wordlist=wordlist, numwords=2, delimiter="")
Example #34
0
 def generate_password(self, passname):
     wordlist = xp.generate_wordlist(xp.locate_wordfile())
     password = xp.generate_xkcdpassword(wordlist)
     print('Generated password: "******"'.format(password))
     self.insert_password(passname, password)
Example #35
0
def main(wf):
  # Imports go here.
  from xkcdpass import xkcd_password as xp
  import string
  from random import SystemRandom

  def genpw(size, chars):
    return ''.join(SystemRandom().choice(chars) for _ in range(size))

  # Defaults
  defaults = {
    'password_length': 10,
    'xkcd_delimiter':  '-',
    'xkcd_minlength':  4,
    'xkcd_maxlength':  10,
    'xkcd_wordllist': 'eff-long', # eff-long (English), spa-mich (Spanish), fin-kotus (Finnish),ita-wiki (Italian), ger-anlx (German)
  }

  # ================================= MAIN ===================================

  # Get args from Workflow, already in normalized Unicode
  password_length = defaults['password_length']
  if len(wf.args) >= 1:
    try:
      password_length = int(wf.args[0].strip())
    except ValueError:
      pass

  # XKCD options
  # TODO: add possibility to change options
  xkcd_wordfile = defaults['xkcd_wordllist']
  xkcd_min_length = defaults['xkcd_minlength']
  xkcd_max_length = defaults['xkcd_maxlength']
  xkcd_delimiter = defaults['xkcd_delimiter']

  # Get XKCD Wordlist and passwords
  mywords = xp.generate_wordlist(wordfile=xkcd_wordfile, min_length=xkcd_min_length, max_length=xkcd_max_length)
  xkcd_3 = xp.generate_xkcdpassword(mywords, 3, False, False, xkcd_delimiter)
  xkcd_4 = xp.generate_xkcdpassword(mywords, 4, False, False, xkcd_delimiter)

  # Allowed Special Characters
  # https://www.owasp.org/index.php/Password_special_characters
  special_chars = "!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"
  full_pw_charset = string.ascii_uppercase + string.ascii_lowercase + string.digits + special_chars
  alnum_pw_charset = string.ascii_uppercase + string.ascii_lowercase + string.digits

  # Generate passwords
  full_pw = genpw(password_length, full_pw_charset)
  alnum_pw = genpw(password_length, alnum_pw_charset)

  # Update workflow if a new version is available.
  if wf.update_available is True:
    wf.add_item('New version available', 'Press enter to install the update.',
      autocomplete='workflow:update',
      icon=ICON_INFO
    )

  # Add password items
  wf.add_item('%d character password' % password_length, full_pw, valid=True, arg=full_pw)
  wf.add_item('%d character password (no special characters)' % password_length, alnum_pw, valid=True, arg=alnum_pw)
  wf.add_item('XKCD Password (3 words)', xkcd_3, valid=True, arg=xkcd_3)
  wf.add_item('XKCD Password (4 words)', xkcd_4, valid=True, arg=xkcd_4)

  # Send output to Alfred.
  wf.send_feedback()
  return 0
Example #36
0
def mkpasswd():
    words = xp.locate_wordfile()
    mywords = xp.generate_wordlist(wordfile=words, min_length=5, max_length=8)
    pwd = xp.generate_xkcdpassword(mywords)

    return pwd.lower()
def generate_normal_pwd():
    # 3 words, no separators between words, second word is CAPITALIZED
    words = xp.generate_xkcdpassword(wordlist=wordlist, numwords=3, delimiter=" ").split()
    return "{0}{1}{2}".format(words[0], str.upper(words[1]), words[2])
def generate_password():
    from xkcdpass import xkcd_password as xp
    mywords = xp.generate_wordlist()
    return xp.generate_xkcdpassword(mywords, numwords=4)
Example #39
0
from xkcdpass import xkcd_password as xp

try:
    numwords = int(input("How many words do you want in you password: "******"Wrong command! ")
    numwords = int(input("Type a number:"))

mylist = []
word = ''
nth_word = 1
isOn = True
while isOn:
    if word == '1':
        isOn = False
    else:
        word = input(f"[{nth_word}] word:")
        nth_word += 1
        if word != '1':
            mylist.append(word)
            print("Type '1' to generate password!")

print(xp.generate_xkcdpassword(mylist, delimiter="", numwords=numwords))
 def test_acrostic(self):
     word = "face"
     result = xkcd_password.generate_xkcdpassword(
         self.wordlist_small,
         acrostic=word)
     self.assertEqual("".join(map(lambda x: x[0], result.split())), word)
Example #41
0
 def generate(self, numwords=6, acrostic=False, delimiter=" "):
     return xp.generate_xkcdpassword(wordlist=self.words,
                                     numwords=numwords,
                                     interactive=False,
                                     acrostic=acrostic,
                                     delimiter=delimiter)
 def test_delim(self):
     tdelim = "_"
     result = xkcd_password.generate_xkcdpassword(
         self.wordlist_small,
         delimiter=tdelim)
     self.assertIsNotNone(re.match('([a-z]+(_|$))+', result))
 def test_acrostic(self):
     word = "face"
     result = xkcd_password.generate_xkcdpassword(self.wordlist_small,
                                                  acrostic=word)
     self.assertEqual("".join(map(lambda x: x[0], result.split())), word)
def generate_weak_pwd():
    # 2 words, no separators between words
    return xkcd_password.generate_xkcdpassword(wordlist=app_config.words,
                                               numwords=2,
                                               delimiter="")
 def test_delim(self):
     tdelim = "_"
     result = xkcd_password.generate_xkcdpassword(self.wordlist_small,
                                                  delimiter=tdelim)
     self.assertIsNotNone(re.match('([a-z]+(_|$))+', result))
Example #46
0
def generate_password(member):
    from xkcdpass import xkcd_password as xp
    wordfile = xp.locate_wordfile()
    mywords = xp.generate_wordlist(wordfile=wordfile, min_length=8, max_length=10)
    password = xp.generate_xkcdpassword(mywords, numwords=2, delimiter='').lower().translate(None, ' -_')
    return(password)