Skip to content

Commit

Permalink
Added Password Generator plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
iamnishant14 committed Mar 12, 2019
1 parent 498355c commit b011c7d
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 59 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.

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 b011c7d

Please sign in to comment.