Simplify the password generator code

This commit is contained in:
Scott Wallace 2019-01-04 12:15:02 +00:00
parent 1278582f49
commit e908241913

View file

@ -6,16 +6,8 @@ Attributes:
""" """
import sys import sys
import logging
import optparse import optparse
import os
try:
import OpenSSL
except ImportError:
logging.error('Missing PyOpenSSL.')
logging.debug('Try `pip install pyopenssl`')
sys.exit(1)
import base64 import base64
LENGTH = 16 LENGTH = 16
@ -27,7 +19,7 @@ def generate(length):
Args: Args:
length (int): length of string to return length (int): length of string to return
""" """
return base64.encodestring(OpenSSL.rand.bytes(256))[:length] return base64.encodestring(os.urandom(256))[:length]
def main(): def main():