Skip to main content

Module Overview

The Password Generator package provides three main components:
  • list_elements class: Generates random selections from numbers or characters
  • password_generator() function: Creates passwords from provided lists
  • password() function: High-level password generation with defaults

Classes

list_elements

A class that generates lists of random numbers or characters based on the input element.

Constructor

int | list
required
The input element used for generating random selections. Can be:
  • An integer: Used as the range for number generation (0 to element-1)
  • A list: Used as the source for character selection
Example:

Methods

select_num()
Generates a list of 50 random numbers within the specified range.
list
A list of 50 randomly selected numbers from the range [0, element). If an error occurs, prints an error message.
Example:
Error Handling:
  • Returns error message if the element value is less than 50
  • Prints: "Error generating list of numbers -> {error_details}"

select_char()
Randomly selects up to 5 unique characters from the provided list.
list
A list of unique characters selected randomly from the element list, with a maximum of 5 characters. If an error occurs, prints an error message.
Example:
Note: The function uses list(set(chars)) which removes duplicates, so the returned list may contain fewer than 5 characters if duplicates were selected. Error Handling:
  • Prints: "Error generating character list -> {error_details}"

Functions

password_generator()

Generates a random 10-character password using the provided lists of numbers, strings, and special characters.

Parameters

list
required
A list of numbers that can be used in the password generation process.
list
required
A list of strings (typically lowercase letters) that will be used to generate the password.
list
required
A list of special characters such as !@#$%^&*().

Returns

str
A randomly generated 10-character password combining elements from all three input lists. The password follows the pattern: special_char + number + letter + special_char + UPPERCASE_letter + letter + number + letter + letter + special_char

Implementation Details

  • Generates 50 candidate passwords
  • Ensures uniqueness by checking against previously generated passwords
  • Randomly selects one password from the candidates
  • One character is automatically uppercased (position 5)
Example:
Error Handling:
  • Prints: "Error generating password -> {error_details}"

password()

High-level function that generates a password with predefined character sets and random selection parameters.

Parameters

No parameters required. Uses internal defaults.

Returns

str
A randomly generated 10-character password using:
  • Numbers: 50 random numbers from range [51, 4000)
  • Letters: 5 random lowercase letters from a-z
  • Special characters: 5 random characters from the set !"#$%&'()*+,-./:;<=>?@[]^_{|}~¡¿°€ and backtick

Default Character Sets

The function uses these predefined sets:
Example:
Error Handling:
  • Prints: "Error in generating data collection to generate the password -> {error_details}"

Usage Flow

Here’s how the components work together:

Module Information

string
Current version: 0.6
string
Edizon Alexander Meza Leal ([email protected])
string
Apache Software License 2.0