Python Forum
mkpw: rewriting in python 3
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mkpw: rewriting in python 3
#7
Here's something basic:

import random, string, sys

rand = random.SystemRandom()
chars = string.ascii_letters + string.digits + string.punctuation
length = int(sys.argv[1])

# if the entire password needs to be unique, just set this to 0
allowed_repetition = 2
min_unique = length - allowed_repetition

pword = ""
while not len(set(pword)) >= min_unique:
   pword = "".join(rand.choice(chars) for _ in range(length))
print(pword)
Reply


Messages In This Thread
mkpw: rewriting in python 3 - by Skaperen - Mar-10-2017, 05:33 AM
RE: mkpw: rewriting in python 3 - by varung1985 - Mar-16-2017, 10:07 AM
RE: mkpw: rewriting in python 3 - by Skaperen - Mar-17-2017, 05:49 AM
RE: mkpw: rewriting in python 3 - by Ofnuts - Mar-16-2017, 01:01 PM
RE: mkpw: rewriting in python 3 - by wavic - Mar-17-2017, 08:13 AM
RE: mkpw: rewriting in python 3 - by Larz60+ - Mar-17-2017, 01:37 PM
RE: mkpw: rewriting in python 3 - by Skaperen - Mar-18-2017, 02:23 AM
RE: mkpw: rewriting in python 3 - by nilamo - Mar-17-2017, 06:55 PM
RE: mkpw: rewriting in python 3 - by snippsat - Mar-17-2017, 07:38 PM
RE: mkpw: rewriting in python 3 - by nilamo - Mar-17-2017, 07:42 PM
RE: mkpw: rewriting in python 3 - by wavic - Mar-18-2017, 11:28 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Rewriting an applications in Python falsedmitri 4 2,881 Jun-03-2019, 01:42 PM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020