We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 9488683 + 1290b93 commit 7eb89c3Copy full SHA for 7eb89c3
random_password_generator.py
@@ -0,0 +1,22 @@
1
+import secrets
2
+import string
3
+
4
+letters = string.ascii_letters
5
+digits = string.digits
6
+special_chars = string.punctuation
7
8
+alphabet = letters + digits + special_chars
9
10
+# fix password length
11
+pwd_length = 12
12
13
+# generate password meeting constraints
14
+while True:
15
+ pwd = ''
16
+ for i in range(pwd_length):
17
+ pwd += ''.join(secrets.choice(alphabet))
18
19
+ if (any(char in special_chars for char in pwd) and
20
+ sum(char in digits for char in pwd) >= 2):
21
+ break
22
+print(pwd)
0 commit comments