aboutsummaryrefslogtreecommitdiffstats
path: root/gdpr_obfuscator/obfuscate.py
blob: 1b6cf0ca404ce27f0c06b5491edcf1ee08ed2c5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from typing import List, Dict


def obfuscate(
    data: List[Dict[str, str]], pii_fields: List[str]
) -> List[Dict[str, str]]:
    """
    A function to obfuscate PII fields in a list of dictionaries, replacing
    sensitive values with a string of asterisks.
    """

    return [
        {k: ("***" if k in pii_fields else v) for k, v in record.items()}
        for record in data
    ]
git.ajschof.me — hosted by ajschofield — powered by cgit