mlox.utils

def encrypt_existing_json_file(path: str, password: str) -> None:

Reads a plain-text JSON file, encrypts its content, and overwrites the file.

def dataclass_to_dict(obj: Any) -> Dict:
def encrypt_dict(my_data: Dict, password: str) -> str:

Saves a dictionary to an encrypted JSON file.

def decrypt_dict(data: str, password: str) -> Dict:
def save_to_json(my_data: Dict, path: str, password: str, encrypt: bool = True) -> None:

Saves a dictionary to an encrypted JSON file.

def load_from_json(path: str, password: str, encrypted: bool = True) -> Any:
def dict_to_dataclass(data: Dict, hooks: Optional[List[Any]] = None) -> Any:
def generate_password(length: int = 10, with_punctuation: bool = False) -> str:

Generate a random password with at least 3 digits, 1 uppercase letter, and 1 lowercase letter.

Parameters
  • length: Length of the password
  • with_punctuation: Include punctuation characters in the password
Returns

Generated password

def generate_username(user_prefix: str = 'mlox') -> str:
def generate_pw(len: int = 20) -> str:
def auto_map_ports( used_ports: List[int], requested_ports: Dict[str, int], ub: int = 65535, lb: int = 1024) -> Dict[str, int]:

Automatically assign ports to services in the bundle based on the provided port mapping. If a service's port is already set, it will not be changed.