Skip to content

Instantly share code, notes, and snippets.

@jiankaiwang
Created September 10, 2018 03:10
Show Gist options
  • Save jiankaiwang/18321132b53a171b6780df8b857d53c9 to your computer and use it in GitHub Desktop.
Save jiankaiwang/18321132b53a171b6780df8b857d53c9 to your computer and use it in GitHub Desktop.
generate several passwords in python
# coding: utf8
# desc: generate several passwords in python
import random
sets = (int)(input("How many passwords you need ? "))
pwdLen = (int)(input("The length of each password ? "))
pwdComposition = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789^&*()_"
pwdMaterial = []
for index in range(0, len(pwdComposition), 1):
pwdMaterial.append(pwdComposition[index])
for index in range(0,sets,1):
print("Password %d : %s" % (index, "".join(random.sample(pwdMaterial, pwdLen))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment