### CLI Usage Patterns Source: https://context7.com/mevdschee/lesspass.py/llms.txt Examples of using the LessPass command-line interface for generating passwords with different profile configurations. ```bash # Install CLI by creating symlink ln -s /path/to/cli.py /usr/local/bin/lesspass # Usage pattern 1: Profile with site/login override # Uses ~/.lesspass/banking.json but overrides site and login lesspass banking mybank.com john.doe # Prompts: LessPass Master Password: # Output: generated password # Usage pattern 2: Profile with embedded credentials # ~/.lesspass/mybank.json contains: {"site": "mybank.com", "login": "john.doe", "length": 20} lesspass mybank # Prompts: LessPass Master Password: # Output: generated password # Usage pattern 3: Default profile with site/login lesspass example.org contact@example.org # Prompts: LessPass Master Password: # Output: generated password (uses default settings) # Example profile file (~/.lesspass/github.json): # { # "site": "github.com", # "login": "myusername", # "length": 20, # "symbols": false, # "counter": 1 # } ``` -------------------------------- ### Configure Password Profiles Source: https://context7.com/mevdschee/lesspass.py/llms.txt Reference for password profile configuration options and common usage examples. ```python # Complete profile configuration reference password_profile = { # Character set options (all default to True) 'lowercase': True, # Include a-z 'uppercase': True, # Include A-Z 'numbers': True, # Include 0-9 'symbols': True, # Include !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ # Password length (default: 16) 'length': 16, # Counter for generating multiple passwords per site (default: 1) 'counter': 1, # Cryptographic parameters (advanced) 'digest': 'sha256', # Hash algorithm (sha256, sha512, etc.) 'iterations': 100000, # PBKDF2 iterations 'keylen': 32, # Key length in bytes # Version (internal use) 'version': 2 } # Common profile examples: # High-security banking password banking_profile = { 'length': 24, 'counter': 1 } # Legacy system (alphanumeric only) legacy_profile = { 'length': 12, 'symbols': False } # PIN code pin_profile = { 'length': 4, 'lowercase': False, 'uppercase': False, 'symbols': False } # Rotated password (increment counter) rotated_profile = { 'length': 16, 'counter': 2 # Generate new password for same site/login } ``` -------------------------------- ### Install CLI via symlink Source: https://github.com/mevdschee/lesspass.py/blob/master/README.md Create a symbolic link to the CLI script within a directory included in the system PATH. ```bash ln -s ~kacper/data/bin/lesspass $(realpath ./cli.py) ``` -------------------------------- ### Get Password Profile with LessPass Python Source: https://context7.com/mevdschee/lesspass.py/llms.txt Use `_get_password_profile` to retrieve default settings or merge custom options with defaults. This function ensures all profile fields are populated. ```python from lesspass.lesspass import _get_password_profile # Get default profile default_profile = _get_password_profile(None) print(default_profile) # Output: { # 'lowercase': True, # 'uppercase': True, # 'numbers': True, # 'symbols': True, # 'digest': 'sha256', # 'iterations': 100000, # 'keylen': 32, # 'length': 16, # 'counter': 1, # 'version': 2 # } ``` ```python # Merge custom options with defaults custom_profile = _get_password_profile({ 'length': 20, 'symbols': False, 'iterations': 50000 }) print(custom_profile['length']) # Output: 20 print(custom_profile['symbols']) # Output: False print(custom_profile['iterations']) # Output: 50000 print(custom_profile['lowercase']) # Output: True (default preserved) ``` -------------------------------- ### Get Character Set with LessPass Python Source: https://context7.com/mevdschee/lesspass.py/llms.txt Use `_get_set_of_characters` to construct the character set for password generation. By default, it includes lowercase, uppercase, numbers, and symbols. ```python from lesspass.lesspass import _get_set_of_characters # Default: all character types (94 characters total) chars = _get_set_of_characters() print(len(chars)) # Output: 94 # Contains: a-z (26) + A-Z (26) + 0-9 (10) + symbols (32) ``` -------------------------------- ### Execute CLI commands Source: https://github.com/mevdschee/lesspass.py/blob/master/README.md Usage patterns for the CLI tool, including profile-based generation and direct parameter passing. ```bash cli.py file site login ``` ```bash cli.py file ``` ```bash cli.py site login ``` -------------------------------- ### Generate Character Sets Source: https://context7.com/mevdschee/lesspass.py/llms.txt Demonstrates how to retrieve specific character sets for password generation using _get_set_of_characters. ```python # Alphanumeric only (no symbols) chars = _get_set_of_characters(['lowercase', 'uppercase', 'numbers']) print(chars) # Output: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 print(len(chars)) # Output: 62 # Lowercase only chars = _get_set_of_characters(['lowercase']) print(chars) # Output: abcdefghijklmnopqrstuvwxyz # Numbers only chars = _get_set_of_characters(['numbers']) print(chars) # Output: 0123456789 # Symbols only chars = _get_set_of_characters(['symbols']) print(chars) # Output: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ ``` -------------------------------- ### Render Passwords from Entropy Source: https://context7.com/mevdschee/lesspass.py/llms.txt Converts entropy bytes into a password string based on a profile. Ensures at least one character from each enabled type is included. ```python from lesspass.lesspass import _get_password_profile, _render_password entropy = 'dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e' # Default length (16 characters) profile = _get_password_profile({}) password = _render_password(entropy, profile) print(password) # Output: WHLpUL)e00[iHR+w print(len(password)) # Output: 16 # Custom length (20 characters) profile = _get_password_profile({'length': 20}) password = _render_password(entropy, profile) print(len(password)) # Output: 20 # Short password (6 chars) - still includes all character types profile = _get_password_profile({'length': 6}) password = _render_password(entropy, profile) print(len(password)) # Output: 6 # Contains at least one lowercase, uppercase, number, and symbol ``` -------------------------------- ### Run tests Source: https://github.com/mevdschee/lesspass.py/blob/master/README.md Execute the test suite using the pytest module. ```bash python -m py.test ``` -------------------------------- ### generate_password Source: https://context7.com/mevdschee/lesspass.py/llms.txt The main entry point for generating passwords. Takes a site, login, master password, and optional profile configuration to produce a deterministic password. ```APIDOC ## generate_password ### Description The main entry point for generating passwords. Takes a site, login, master password, and optional profile configuration to produce a deterministic password that will always be the same given the same inputs. ### Method ```python lesspass.generate_password( site: str, login: str, master_password: str, password_profile: dict = None ) -> str ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from lesspass import lesspass # Basic usage with default settings password = lesspass.generate_password( site='example.org', login='contact@example.org', master_password='password' ) print(password) # Custom profile: 14 characters, no symbols, counter 2 password = lesspass.generate_password( site='example.org', login='contact@example.org', master_password='password', password_profile={ 'length': 14, 'counter': 2, 'symbols': False } ) print(password) ``` ### Response #### Success Response (200) - **password** (str) - The generated deterministic password. #### Response Example ```json { "password": "WHLpUL)e00[iHR+w" } ``` ``` -------------------------------- ### Generate Password with LessPass Python Source: https://context7.com/mevdschee/lesspass.py/llms.txt Use `generate_password` for basic or custom password generation. Specify site, login, master password, and an optional profile for length, character sets, and counters. ```python from lesspass import lesspass # Basic usage with default settings (16 chars, all character types) password = lesspass.generate_password( site='example.org', login='contact@example.org', master_password='password' ) print(password) # Output: WHLpUL)e00[iHR+w ``` ```python # Custom profile: 14 characters, no symbols, counter 2 password = lesspass.generate_password( site='example.org', login='contact@example.org', master_password='password', password_profile={ 'length': 14, 'counter': 2, 'symbols': False } ) print(password) # Output: MBAsB7b1Prt8Sl ``` ```python # Numbers only (6-digit PIN) pin = lesspass.generate_password( site='example.org', login='contact@example.org', master_password='password', password_profile={ 'length': 6, 'counter': 3, 'lowercase': False, 'uppercase': False, 'symbols': False } ) print(pin) # Output: 117843 ``` ```python # No numbers in password password = lesspass.generate_password( site='example.org', login='contact@example.org', master_password='password', password_profile={ 'length': 14, 'numbers': False } ) print(password) # Output: sB>{qF}wN%/-fm ``` -------------------------------- ### _calc_entropy Source: https://context7.com/mevdschee/lesspass.py/llms.txt Calculates the entropy bytes using PBKDF2-HMAC with the configured digest algorithm. The entropy is the cryptographic foundation for password generation. ```APIDOC ## _calc_entropy ### Description Calculates the entropy bytes using PBKDF2-HMAC with the configured digest algorithm. The entropy is the cryptographic foundation for password generation, derived from the site, login, master password, and counter. ### Method ```python lesspass.lesspass._calc_entropy( site: str, login: str, master_password: str, profile: dict ) -> bytes ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from lesspass.lesspass import _get_password_profile, _calc_entropy site = 'example.org' login = 'contact@example.org' master_password = 'password' # Default parameters profile = _get_password_profile({}) entropy = _calc_entropy(site, login, master_password, profile) print(entropy.decode('utf-8')) # Custom parameters profile = _get_password_profile({ 'iterations': 8192, 'keylen': 16, 'digest': 'sha512' }) entropy = _calc_entropy(site, login, master_password, profile) print(entropy.decode('utf-8')) # Different counter profile = _get_password_profile({'iterations': 1, 'keylen': 16, 'counter': 2}) entropy = _calc_entropy(site, login, master_password, profile) print(entropy.decode('utf-8')) ``` ### Response #### Success Response (200) - **entropy** (bytes) - The calculated entropy bytes. #### Response Example ```json { "entropy": "dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e" } ``` ``` -------------------------------- ### _get_password_profile Source: https://context7.com/mevdschee/lesspass.py/llms.txt Internal function that merges user-provided profile options with default settings. Returns a complete password profile dictionary. ```APIDOC ## _get_password_profile ### Description Internal function that merges user-provided profile options with default settings. Returns a complete password profile dictionary with all required fields populated. ### Method ```python lesspass.lesspass._get_password_profile( options: dict = None ) -> dict ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from lesspass.lesspass import _get_password_profile # Get default profile default_profile = _get_password_profile(None) print(default_profile) # Merge custom options with defaults custom_profile = _get_password_profile({ 'length': 20, 'symbols': False, 'iterations': 50000 }) print(custom_profile['length']) print(custom_profile['symbols']) print(custom_profile['iterations']) print(custom_profile['lowercase']) ``` ### Response #### Success Response (200) - **profile** (dict) - A dictionary containing the complete password profile settings. #### Response Example ```json { "profile": { "lowercase": True, "uppercase": True, "numbers": True, "symbols": True, "digest": "sha256", "iterations": 100000, "keylen": 32, "length": 16, "counter": 1, "version": 2 } } ``` ``` -------------------------------- ### Calculate Entropy with LessPass Python Source: https://context7.com/mevdschee/lesspass.py/llms.txt Use `_calc_entropy` to compute entropy bytes using PBKDF2-HMAC. This function requires site, login, master password, and a profile dictionary. Different parameters or counters yield different entropy. ```python from lesspass.lesspass import _get_password_profile, _calc_entropy site = 'example.org' login = 'contact@example.org' master_password = 'password' # Default parameters (SHA256, 100000 iterations, 32-byte key) profile = _get_password_profile({}) entropy = _calc_entropy(site, login, master_password, profile) print(entropy.decode('utf-8')) # Output: dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e ``` ```python # Custom parameters (SHA512, 8192 iterations, 16-byte key) profile = _get_password_profile({ 'iterations': 8192, 'keylen': 16, 'digest': 'sha512' }) entropy = _calc_entropy(site, login, master_password, profile) print(entropy.decode('utf-8')) # Output: fff211c16a4e776b3574c6a5c91fd252 ``` ```python # Different counter produces different entropy profile = _get_password_profile({'iterations': 1, 'keylen': 16, 'counter': 2}) entropy = _calc_entropy(site, login, master_password, profile) print(entropy.decode('utf-8')) # Output: ddfb1136260f930c21f6d72f6eddbd40 ``` -------------------------------- ### _get_set_of_characters Source: https://context7.com/mevdschee/lesspass.py/llms.txt Constructs the character set used for password generation based on the enabled character type rules. Returns a concatenated string of all allowed characters. ```APIDOC ## _get_set_of_characters ### Description Constructs the character set used for password generation based on the enabled character type rules. Returns a concatenated string of all allowed characters. ### Method ```python lesspass.lesspass._get_set_of_characters( password_profile: dict = None ) -> str ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from lesspass.lesspass import _get_set_of_characters # Default: all character types chars = _get_set_of_characters() print(len(chars)) # Example with custom profile (e.g., only lowercase and numbers) custom_profile = { 'lowercase': True, 'uppercase': False, 'numbers': True, 'symbols': False } chars = _get_set_of_characters(custom_profile) print(chars) ``` ### Response #### Success Response (200) - **characters** (str) - A string containing all allowed characters for password generation. #### Response Example ```json { "characters": "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.