From cbbd618e0bf253f3a6449fd58c321f99672874e6 Mon Sep 17 00:00:00 2001 From: SHUBHAM GARG <52582943+shub-garg@users.noreply.github.com> Date: Tue, 25 Aug 2020 15:31:15 +0530 Subject: [PATCH] Added a Random_Email_Generator to the list of projects! (#141) * Added Random Email Generator Python Script * Create README.md * Update README.md * Update Random_email_generator.py * Update Random_email_generator.py * Update README.md * Added Random Email Generator Python Script Co-authored-by: shub-garg --- README.md | 1 + Random_Email_Generator/README.md | 25 ++++++++ .../Random_email_generator.py | 62 +++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 Random_Email_Generator/README.md create mode 100644 Random_Email_Generator/Random_email_generator.py diff --git a/README.md b/README.md index ffcb02a..86c9c13 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,7 @@ So far, the following projects have been integrated to this repo: |[send_whatsapp_message](send_whatsapp_message)|[Mukesh Prasad](https://github.com/mukeshprasad)| |[YTS Torrents](yts_torrents)|[Mayank Nader](https://github.com/makkoncept)| |[COVID visualiser (real-time) ](covdi_visualiser)|[Tushar Gupta](https://github.com/tushar5526)| +|[Random_Email_Generator](Random_Email_Generator)|[Shubham Garg](https://github.com/shub-garg)| ## How to use : diff --git a/Random_Email_Generator/README.md b/Random_Email_Generator/README.md new file mode 100644 index 0000000..28e63b7 --- /dev/null +++ b/Random_Email_Generator/README.md @@ -0,0 +1,25 @@ +# Programs +## [Random_Email_Generator.py](./Random_email_generator.py) +This program randomly generates an email address using a mix of letters, both caps on and off, numbers, and punctuation, then outputs the results. + + +# Requirements +* [Random_Email_Generator.py](./Random_email_generator.py) can use Python 3 and higher or Python 2 and higher. +Moreover, you might also have to install progressbar library in your system. +```bash +$ pip install progressbar +``` + +# Usage + +For Windows users: + +```bash +$ python Random_email_generator.py +``` + +For Mac/Linux/Unix users: + +```bash +$ ./Random_email_generator.py +``` diff --git a/Random_Email_Generator/Random_email_generator.py b/Random_Email_Generator/Random_email_generator.py new file mode 100644 index 0000000..a385fd6 --- /dev/null +++ b/Random_Email_Generator/Random_email_generator.py @@ -0,0 +1,62 @@ +import random +import string +import csv +import progressbar + +''' +Asks user for how many emails they want generated. Must be Integer. +If not an integer, keeps recursively cycling back until it gets an integer. +''' +def getcount(): + rownums = input("How many email addresses?: ") + try: + rowint = int(rownums) + return rowint + except ValueError: + print ("Please enter an integer value") + return getcount() + +''' +Creates a random string of digits between 1 and 20 characters alphanumeric and adds it to a fake domain and fake extension +Most of these emails are completely bogus (eg - gmail.gov) but will meet formatting requirements for my purposes +''' +def makeEmail(): + extensions = ['com','net','org','gov'] + domains = ['gmail','yahoo','comcast','verizon','charter','hotmail','outlook','frontier'] + + winext = extensions[random.randint(0,len(extensions)-1)] + windom = domains[random.randint(0,len(domains)-1)] + + acclen = random.randint(1,20) + + winacc = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(acclen)) + + finale = winacc + "@" + windom + "." + winext + return finale + +#save count to var +howmany = getcount() + +#counter for While loop +counter = 0 + +#empty array for loop +emailarray = [] + +#uses counter to figure out how many emails to keep making + +print ("Creating email addresses...") +print ("Progress: ") + +prebar = progressbar.ProgressBar(maxval=int(howmany)) + +for i in prebar(range(howmany)): + while counter < howmany: + emailarray.append(str(makeEmail())) + counter = counter+1 + prebar.update(i) + +print ("Creation completed.") + +for i in emailarray: + print(i)