{"id":122,"date":"2024-03-23T20:19:50","date_gmt":"2024-03-23T20:19:50","guid":{"rendered":"https:\/\/paradoxa.me\/?p=122"},"modified":"2024-04-05T13:29:47","modified_gmt":"2024-04-05T13:29:47","slug":"python-password-generator-code","status":"publish","type":"post","link":"https:\/\/paradoxa.me\/index.php\/2024\/03\/23\/python-password-generator-code\/","title":{"rendered":"~ Python password generator code"},"content":{"rendered":"<h1 style=\"text-align: center;\">Python password generator code<\/h1>\n<h2 style=\"text-align: center;\">To run the code inside the terminal type: python <em>filename.py <\/em><\/h2>\n<p style=\"text-align: center;\">NOTE: THE SCRIPT WAS WORKING BUT,<br \/>\nAFTER COPYING AND PASTE IT IN A TEXTFILE.PY<br \/>\nI DISCOVER A COUPLE OF PROBLEMS, MAYBE DUE TO THE WEBSITE FONT:<\/p>\n<p style=\"text-align: center;\">REPLACE ALL THE\u00a0\u00a0 <strong>&#8221; \u00a0<\/strong> WITH THE SAME SYMBOLS<br \/>\nREPLACE ALL THE\u00a0\u00a0 <strong>&#8211;<\/strong>\u00a0\u00a0 WITH THE SAME SYMBOLS<\/p>\n<p>&nbsp;<\/p>\n<p>import secrets<br \/>\nimport string<br \/>\nimport random<\/p>\n<p>lower = string.ascii_lowercase<br \/>\nupper = string.ascii_uppercase<br \/>\ndigits = string.digits<br \/>\nspecial = string.punctuation<br \/>\nallChars = lower + upper + digits + special<br \/>\npassword = &#8220;&#8221;<\/p>\n<p>pwLen = int(input(&#8220;How long should the password be? &#8220;))<br \/>\nminUpper = int(input(&#8220;Minimum Upper Case: &#8220;))<br \/>\nminLower = int(input(&#8220;Minimum Lower Case &#8220;))<br \/>\nminDigits = int(input(&#8220;Minimum Numbers: &#8220;))<br \/>\nminSpec = int(input(&#8220;Minimum Special: &#8220;))<\/p>\n<p>for i in range(minUpper):<br \/>\n<em>[PRESS TAB]<\/em>password += &#8220;&#8221;.join(random.choice(secrets.choice(upper)))<\/p>\n<p>for i in range(minLower):<br \/>\n<em>[PRESS TAB]<\/em>password += &#8220;&#8221;.join(random.choice(secrets.choice(lower)))<\/p>\n<p>for i in range(minDigits):<br \/>\n<em>[PRESS TAB]<\/em>password += &#8220;&#8221;.join(random.choice(secrets.choice(digits)))<\/p>\n<p>for i in range(minSpec):<br \/>\n<em>[PRESS TAB]<\/em>password += &#8220;&#8221;.join(random.choice(secrets.choice(special)))<\/p>\n<p>remaining = pwLen &#8211; minUpper &#8211; minLower &#8211; minDigits &#8211; minSpec<\/p>\n<p>for i in range(remaining):<br \/>\npassword += &#8220;&#8221;.join(random.choice(secrets.choice(allChars)))<\/p>\n<p>password = list(password)<br \/>\nrandom.shuffle(password)<\/p>\n<p>print(&#8220;&#8221;.join(password))<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python password generator code To run the code inside the terminal type: python filename.py NOTE: THE SCRIPT WAS WORKING BUT, AFTER COPYING AND PASTE IT IN A TEXTFILE.PY I DISCOVER [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":34,"footnotes":""},"categories":[33,19],"tags":[36,35,34],"class_list":["post-122","post","type-post","status-publish","format-standard","hentry","category-python","category-software","tag-code","tag-password","tag-python"],"_links":{"self":[{"href":"https:\/\/paradoxa.me\/index.php\/wp-json\/wp\/v2\/posts\/122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/paradoxa.me\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/paradoxa.me\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/paradoxa.me\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/paradoxa.me\/index.php\/wp-json\/wp\/v2\/comments?post=122"}],"version-history":[{"count":6,"href":"https:\/\/paradoxa.me\/index.php\/wp-json\/wp\/v2\/posts\/122\/revisions"}],"predecessor-version":[{"id":156,"href":"https:\/\/paradoxa.me\/index.php\/wp-json\/wp\/v2\/posts\/122\/revisions\/156"}],"wp:attachment":[{"href":"https:\/\/paradoxa.me\/index.php\/wp-json\/wp\/v2\/media?parent=122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/paradoxa.me\/index.php\/wp-json\/wp\/v2\/categories?post=122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/paradoxa.me\/index.php\/wp-json\/wp\/v2\/tags?post=122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}