Created
March 29, 2018 20:14
-
-
Save jahanideveloper/92bcc71cb79b2629c74fcc5684746ede to your computer and use it in GitHub Desktop.
ساخت کلمه عبور اتفاقی
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random,os,sys | |
def clear(): | |
if os.name == 'nt': | |
os.system('cls') | |
else: | |
os.system('clear') | |
def show_help(): | |
print(""" | |
###### HELP ###### | |
baray khoroj az barname "q" ra vared konid | |
bray namayesh #help# az kalane 'help' estefade konid | |
bray ramz beyn 3 ta 5 ragham adad '1' ya 'low' ra vared konid | |
bray ramz beyn 6 ta 10 ragham adad '2' ya 'medium' ra vared konid | |
bray ramz beyn 11 ta 20 ragham adad '3' ya 'high' ra vared konid | |
""") | |
def make_pass(user_choice): | |
if user_choice == 'low' or user_choice == '1': | |
passlen = random.randrange(3,5) | |
elif user_choice == 'medium' or user_choice == '2': | |
passlen = random.randrange(6,10) | |
elif user_choice == 'high' or user_choice == '3': | |
passlen = random.randrange(11,20) | |
else: | |
return show_help() | |
s = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234560!٬@#$%^&*()_+?><' | |
p = "".join(random.sample(s,passlen)) | |
return p | |
while True: | |
show_help() | |
user = input(":> ").lower() | |
if user == 'q': | |
print("by!") | |
sys.exit() | |
elif user == 'help': | |
clear() | |
show_help() | |
else: | |
clear() | |
print("##########ramz entekhabi shoma ----> {} ##########".format(make_pass(user))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment