Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mkpw: rewriting in python 3
Well, here is a something small:

import click
from string import ascii_letters, digits, punctuation
from random import SystemRandom

@click.argument('length', default=8, nargs=1, type=int)
@click.argument('char_set', default='anum', type=click.Choice(['alfa', 'num', 'anum', 'all']))
@click.argument('additional', default="", type=str)
def gen_pass(length, char_set, additional):
    chars = {'alfa': ascii_letters,
            'anum': ascii_letters + digits,
            'all': ascii_letters + digits + punctuation}

    ch_set = chars[char_set] + additional

    choice = SystemRandom().choice

    passwd = "".join(choice(ch_set) for _ in range(length))


if __name__ == '__main__':
It generates eight symbols length alfanumerical password as default.
The first parameter is the length as an integer.
The second is between alfa: lower-upper ascii letters, num: digits, anum: ascii_letters + digits, all: letters + digits + puncutuation
The third one is quoted string of aditional characters

I did not separate lower and upper case letters and ther is no help.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."

Top Page

Forum Jump:

Users browsing this thread: 1 Guest(s)