API Reference

maskme.engine

Primary engine of anonymization. Orchestrates rule traversal, strategy resolution, and the application of transformations.

class maskme.core.engine.MaskMe(rules: Dict[str, Any], salt: str = '')[source]

Bases: object

Agnostic data anonymization engine

Scans nested dictionaries and applies anonymization strategies defined by a set of rules.

mask(data_iterator: Iterable[Dict]) Generator[Dict, None, None][source]

Anonymizes records one by one to conserve memory.

Parameters:

data_iterator – Dictionary generator or list.

Yields:

The next anonymized record.

maskme.strategies.hashing.apply(value: Any, salt: str = '', algo: str = 'sha256', **kwargs) str[source]

Transform a value into a hex digest using a specified hashing algorithm.

The value and salt are concatenated before hashing. If the requested algorithm is unavailable, a warning is emitted and sha256 is used as a fallback.

Parameters:
  • value – The input value to hash. Returns “” if None.

  • salt – An optional string appended to the value before hashing.

  • algo – The hashing algorithm to use (e.g. “sha256”, “sha512”, “blake2b”). Must be supported by hashlib. Defaults to “sha256”.

  • **kwargs – Accepted for interface consistency; not used.

Returns:

The hexadecimal digest of the hashed value, or “” if value is None.

Raises:
  • No exception is raised for unsupported algorithms — a warning is

  • emitted and sha256 is used instead.