Skip to content

Commit

Permalink
Merge pull request pyhoneybot#40 from iamnishant14/feature/password_g…
Browse files Browse the repository at this point in the history
…enerator

Feature/password generator
  • Loading branch information
Abdur-rahmaanJ authored Mar 12, 2019
2 parents bef82e0 + b011c7d commit d009c8e
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 60 deletions.
129 changes: 70 additions & 59 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Psst. since i learnt py through this bot, we decided to keep a new-comers friend

## 📌 Contributing Countries

🇲🇺 🇺🇸 🇨🇦 🇦🇷
🇲🇺 🇺🇸 🇨🇦 🇦🇷 🇮🇳

## ✂ Current Features
* 🍬 OOP architecture
Expand Down
81 changes: 81 additions & 0 deletions honeybot/plugins/password_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
"""
[password_generator.py]
Password Generator Plugin
[Author]
Nishant, JPMorgan Chase & Co.
[About]
sends different type of passwords
[Commands]
>>> .passgen <<length>>
returns alphabetic password of specified length
>>> .passgensecure <<length>>
returns secure alphanumeric password of specified length
>>> .passgenalphanum <<length>>
returns alphanumeric password of specified length
>>> .passgenspecialchar <<length>>
returns universally accepted alphanumeric password with special characters of specified length where length >= 4
"""

import string, random, secrets


class Plugin:
def __init__(self):
pass

def __passgen(self, password_length):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(password_length))

def __passgenalphanum(self, password_length):
password_characters = string.ascii_letters + string.digits + string.punctuation
return ''.join(random.choice(password_characters) for i in range(password_length))

def __passgensecure(self, password_length):
password_characters = string.ascii_letters + string.digits + string.punctuation
return ''.join(secrets.choice(password_characters) for i in range(password_length))

def __passgenspecialchar(self, password_length):
randomSource = string.ascii_letters + string.digits + string.punctuation
password = random.choice(string.ascii_lowercase)
password += random.choice(string.ascii_uppercase)
password += random.choice(string.digits)
password += random.choice(string.punctuation)
for i in range(password_length - 4):
password += random.choice(randomSource)
passwordList = list(password)
random.SystemRandom().shuffle(passwordList)
password = ''.join(passwordList)
return password

def run(self, incoming, methods, info):
try:
# if '!~' in info['prefix']:
# print(info)
msgs = info['args'][1:][0].split()
if info['command'] == 'PRIVMSG':
if len(msgs) > 1:
if msgs[0] == '.passgen':
length = msgs[1]
methods['send'](info['address'], self.__passgen(length))
if msgs[0] == '.passgensecure':
length = msgs[1]
methods['send'](info['address'], self.__passgensecure(length))
if msgs[0] == '.passgenalphanum':
length = msgs[1]
methods['send'](info['address'], self.__passgenalphanum(length))
if msgs[0] == '.passgenspecialchar':
length = msgs[1]
if length >= 4:
methods['send'](info['address'], self.__passgenspecialchar(length))
else:
raise Exception('Length od password should be greater than 4.')
except Exception as e:
print('woops plug', e)

0 comments on commit d009c8e

Please sign in to comment.