Created
April 18, 2012 01:52
-
-
Save JasonGiedymin/2410498 to your computer and use it in GitHub Desktop.
Simple password generator created and used at my startup
This file contains 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
''' | |
_) ___| | | _) _| | |
| \___ \ __| __| _` | __| | | | | | |
| | | | ( | | | __| | | | |
_| _____/ \__| _| \__,_| \__| _| _| \__, | | |
____/ | |
@author: [email protected] | |
Quick password generator. | |
This generator is fast, *leaks, and generates *weak passwords :-) | |
Use to create simple strength passwords. | |
* - small lengths cause leaks | |
** - weakest links will always be rng and hashers (speed). | |
''' | |
import getpass | |
import hashlib | |
import os | |
import random | |
import sha | |
import string | |
import uuid | |
def notes(password_length, random_size): | |
print("--------------------------Notes----------------------------") | |
print("- Password lengths are random between 16 and 64 chars in length.") | |
print("- Secondary seeding size is random between 64 and 128 chars in length.") | |
print("- Simple Passwords:") | |
print(" Limited char set, simple, easy to type.") | |
print("- Extended:") | |
print(" Several more characters allowed than simple.") | |
print("- Advanced:") | |
print(" Several more characters allowed than extended.") | |
print("- UUID Passwords:") | |
print(" (node+time) are based on host ID and current time while") | |
print(" (random) are system generated random.") | |
print("- Password Length: %s" % password_length) | |
print("- Random data Length: %s\n" % random_size) | |
def showPasswords(password_data, title_text): | |
# All kinds of cutting weirdness here | |
_x2 = password_length/2 | |
_x3 = len(password_data) - _x2 | |
_sized_password = password_data[0:password_length] | |
_first_half = password_data[0:_x2] | |
_second_half = password_data[_x3:] | |
print("%s" % title_text) | |
print("Short password 1: '%s'" % _sized_password) | |
print("Short password 2: '%s%s'" % (_first_half, _second_half)) | |
print(" Long password 1: '%s'\n" % password_data) | |
def simplePasswords(password): | |
title_text = "--------------Generated Simple Passwords-----------------" | |
showPasswords(password, title_text) | |
def extendedPasswords(password): | |
title_text = "-------------Generated Extended Passwords----------------" | |
showPasswords(password, title_text) | |
def advancedPasswords(password): | |
title_text = "-------------Generated Advanced Passwords----------------" | |
showPasswords(password, title_text) | |
def uuidPasswords(): | |
print("\n--------Generated Random Seeded UUID Passwords-----------") | |
print("UUID 1 (node+time): '%s'" % uuid.uuid1()) | |
print(" UUID 2 (random): '%s'" % uuid.uuid4()) | |
print(" UUID 3 (random): '%s'" % uuid.uuid4()) | |
def spacer(): | |
print("\n-----------------------------------------------------------") | |
def logo(): | |
print(''' | |
_) ___| | | _) _| | |
| \___ \ __| __| _` | __| | | | | | |
| | | | ( | | | __| | | | |
_| _____/ \__| _| \__,_| \__| _| _| \__, | | |
____/ | |
Quick simple strength password generator. | |
''') | |
if __name__ == "__main__": | |
# | |
# Python os.urandom() seeds with current system time. | |
# Just run it! | |
# | |
charset = [chr(i) for i in range(32,38) + range(40,127)] # advanced charset | |
password_length = random.randrange(16, 64, 2) # Suck it up. | |
random_size = random.randrange(64, 128) # If you need larger this is not for you | |
random_data = os.urandom(random_size) | |
random_data_extended = ''.join([random.choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(random_size)]) | |
random_data_advanced = ''.join([random.choice(charset) for i in range(random_size)]) | |
inner_hash = hashlib.sha512( random_data ).hexdigest() # for good luck! | |
outer_hash = hashlib.sha512( inner_hash ).hexdigest() # Oh I'm feeling lucky! | |
spacer() | |
logo() | |
notes(password_length, random_size) | |
simplePasswords(outer_hash) | |
extendedPasswords(random_data_extended) | |
advancedPasswords(random_data_advanced) | |
uuidPasswords() | |
spacer() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment