From e908241913436de1774923648e0454cd2f84cd61 Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Fri, 4 Jan 2019 12:15:02 +0000 Subject: [PATCH] Simplify the password generator code --- bin/genpw | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/bin/genpw b/bin/genpw index 3973464..4e44852 100755 --- a/bin/genpw +++ b/bin/genpw @@ -6,16 +6,8 @@ Attributes: """ import sys -import logging import optparse - -try: - import OpenSSL -except ImportError: - logging.error('Missing PyOpenSSL.') - logging.debug('Try `pip install pyopenssl`') - sys.exit(1) - +import os import base64 LENGTH = 16 @@ -27,7 +19,7 @@ def generate(length): Args: length (int): length of string to return """ - return base64.encodestring(OpenSSL.rand.bytes(256))[:length] + return base64.encodestring(os.urandom(256))[:length] def main():