def GeneratePasswordBase64(passString, passLength):
    """This function creates a SHA-1 hash from the passString. The 40 nibbles of
    this hash are expressed in base64 format and the first passLength characters
    are returned as the generated password"""
    assert passLength <= 160/6  #because each base64 character is derived from 6 bits
    import base64
    return base64.b64encode(sha.sha(passString).hexdigest())[:passLength]
This function creates a SHA-1 hash from the passString. The 40 nibbles of
    this hash are expressed in base64 format and the first passLength characters
    are returned as the generated password
recipes/Python/440564_easy_password_generator_using_standard/recipe-440564.py