Pyworks package¶
Submodules¶
Pyworks.calculator module¶
Pyworks.password_generator module¶
- Pyworks.password_generator.calculate_entropy(password)¶
Calculate the entropy (randomness) of a given password.
- Args:
password (str): The password for which to calculate entropy.
- Returns:
float: The entropy of the password in bits.
- Pyworks.password_generator.export_password(password, export_format)¶
Export a password in a specified format.
- Args:
password (str): The password to be exported. export_format (str): The desired export format (e.g., ‘plain’, ‘base64’, ‘hex’).
- Returns:
str: The exported password in the specified format.
- Pyworks.password_generator.generate_cryptographically_secure_password(length=12, include_uppercase=True, include_lowercase=True, include_digits=True, include_special_chars=True)¶
Generate a cryptographically secure password using the system’s secure random number generator.
- Args:
length (int): The desired length of the password. include_uppercase (bool): Whether to include uppercase letters. include_lowercase (bool): Whether to include lowercase letters. include_digits (bool): Whether to include digits. include_special_chars (bool): Whether to include special characters.
- Returns:
str: The generated cryptographically secure password.
- Pyworks.password_generator.generate_memorable_password(length=12, num_words=3, delimiter='-', include_digits=True, include_special_chars=True)¶
Generate a memorable password by combining common words with numbers and special characters.
- Args:
length (int): The desired length of the password. num_words (int): The number of common words to include in the password. delimiter (str): The character to use as a delimiter between words and other characters. include_digits (bool): Whether to include digits. include_special_chars (bool): Whether to include special characters.
- Returns:
str: The generated memorable password.
- Pyworks.password_generator.generate_multi_word_password(length=12, num_words=3, delimiter='-', include_digits=True, include_special_chars=True)¶
Generate a password composed of multiple words separated by a delimiter.
- Args:
length (int): The desired length of the password. num_words (int): The number of words to include in the password. delimiter (str): The character to use as a delimiter between words. include_digits (bool): Whether to include digits. include_special_chars (bool): Whether to include special characters.
- Returns:
str: The generated multi-word password.
- Pyworks.password_generator.generate_pattern_based_password(pattern, character_sets, length=12)¶
Generate a password based on a specified pattern and custom character sets.
- Args:
pattern (str): The pattern to follow for generating the password. Use ‘C’ for characters, ‘D’ for digits, and ‘S’ for special characters. character_sets (dict): A dictionary containing custom character sets for characters (‘C’), digits (‘D’), and special characters (‘S’). length (int): The desired length of the password.
- Returns:
str: The generated pattern-based password.
- Pyworks.password_generator.generate_personalized_password(name, length=12, include_uppercase=True, include_lowercase=True, include_digits=True, include_special_chars=True)¶
Generate a personalized password based on a given name.
- Args:
name (str): The name to be used as the basis for the personalized password. length (int): The desired length of the password. include_uppercase (bool): Whether to include uppercase letters. include_lowercase (bool): Whether to include lowercase letters. include_digits (bool): Whether to include digits. include_special_chars (bool): Whether to include special characters.
- Returns:
str: The generated personalized password.
- Pyworks.password_generator.generate_pronounceable_password(length=12, include_digits=True, include_special_chars=True)¶
Generate a pronounceable password that resembles a word or phrase from a language.
- Args:
length (int): The desired length of the password. include_digits (bool): Whether to include digits. include_special_chars (bool): Whether to include special characters.
- Returns:
str: The generated pronounceable password.
- Pyworks.password_generator.generate_random_characters(length, include_digits=True, include_special_chars=True)¶
Generate a string of random characters with optional inclusion of digits and special characters.
- Args:
length (int): The desired length of the random character string. include_digits (bool): Whether to include digits. include_special_chars (bool): Whether to include special characters.
- Returns:
str: The generated string of random characters.
- Pyworks.password_generator.score_password_strength(password)¶
Score the strength of a given password based on various criteria.
- Args:
password (str): The password to be scored.
- Returns:
int: A score representing the strength of the password, ranging from 0 (weak) to 5 (strong).
Pyworks.url_sharpner module¶
- Pyworks.url_sharpner.get_url_analytics(short_url)¶
Retrieve analytics for a short URL.
- Args:
short_url (str): The short URL to retrieve analytics for.
- Returns:
dict: A dictionary containing the original URL, creation date, expiration date (if applicable), and click count.
- Pyworks.url_sharpner.resolve_url(short_url)¶
Retrieve the original URL from the short URL.
- Args:
short_url (str): The short URL to be resolved.
- Returns:
str: The original URL, or None if the short URL is not found or expired.
- Pyworks.url_sharpner.shorten_url(original_url, custom_short=None, expiration_days=None)¶
Shorten a URL and store it in the database.
- Args:
original_url (str): The original URL to be shortened. custom_short (str, optional): A custom short URL. If provided, it will be used if available. expiration_days (int, optional): Number of days after which the short URL will expire.
- Returns:
str: The shortened URL.