Skip to main content

dict-field-redacter: A utility to redact sensitive fields in dictionaries. Easily sanitize your data by masking fields like passwords, tokens, secrets and more... Good for Log Sanitization, Data Privacy, and Security.

Project description

DICT_FIELD_REDACTER

🇫🇷 Français

Description

DICT_FIELD_REDACTER est un outil Python permettant de masquer ou supprimer des champs sensibles dans des dictionnaires ou des objets JSON. Idéal pour anonymiser des données avant de les stocker ou de les partager.

Installation

pip install dict-field-redacter

Utilisation

test_data = {
    "user_profile": {
        "username": "john_doe",
        "email": "john@example.com",
        "personal_info": {
            "ssn": "123-45-6789",
            "password": "mySecretPass123",
            "banking": {
                "account_number": "ACC123456789",
                "secret": "bank_secret_key",
                "credit_card": {
                    "number": "4532-1234-5678-9012",
                    "cvv": "123",
                    "pin": "1234"
                }
            }
        }
    },
}
from dict_field_redacter import DICT_FIELD_REDACTER
import json
fields_to_redact = ["email", "password", "secret", "cvv", "pin", "number"]
redacter = DICT_FIELD_REDACTER(fields_to_redact, maskWith="Redacted") # Vous pouvez personnaliser le placeholder avec une valeur de votre choix
# La redaction en mode strict (seuls les champs spécifiés sont redacted, (ceux qui ne sont pas strictement dans la liste restent inchangés))
redacted = redacter.sanitize(test_data, mode="loose")
print(json.dumps(redacted, indent=4))
#{
#    "user_profile": {
#        "username": "john_doe",
#        "email": "Redacted",
#        "personal_info": {
#            "ssn": "123-45-6789",
#            "password": "Redacted",
#            "banking": {
#                "account_number": "Redacted",
#                "secret": "Redacted",
#                "credit_card": {
#                    "number": "4532-1234-5678-9012",
#                    "cvv": "123",
#                    "pin": "1234"
#                }
#            }
#        }
#    },
#}

Contribution

Les contributions sont les bienvenues ! Veuillez ouvrir une issue ou une pull request sur GitHub.

Licence

Ce projet est sous licence MIT.


🇬🇧 English

Description

DICT_FIELD_REDACTER is a Python tool that allows you to mask or remove sensitive fields in dictionaries or JSON objects. Ideal for anonymizing data before storing or sharing it.

Installation

pip install dict-field-redacter

Usage

test_data = {
    "user_profile": {
        "username": "john_doe",
        "email": "john@example.com",
        "personal_info": {
            "ssn": "123-45-6789",
            "password": "mySecretPass123",
            "banking": {
                "account_number": "ACC123456789",
                "secret": "bank_secret_key",
                "credit_card": {
                    "number": "4532-1234-5678-9012",
                    "cvv": "123",
                    "pin": "1234"
                }
            }
        }
    },
}
from dict_field_redacter import DICT_FIELD_REDACTER
import json
fields_to_redact = ["email", "password", "secret", "cvv", "pin", "number"]
redacter = DICT_FIELD_REDACTER(fields_to_redact, placeHolder="Redacted") # You can customize the placeholder
# 
redacted = redacter.sanitize(test_data, mode="loose")
print(json.dumps(redacted, indent=4))
#{
#    "user_profile": {
#        "username": "john_doe",
#        "email": "Redacted",
#        "personal_info": {
#            "ssn": "123-45-6789",
#            "password": "Redacted",
#            "banking": {
#                "account_number": "Redacted",
#                "secret": "Redacted",
#                "credit_card": {
#                    "number": "4532-1234-5678-9012",
#                    "cvv": "123",
#                    "pin": "1234"
#                }
#            }
#        }
#    },
#}

Contribution

Contributions are welcome! Please open an issue or a pull request on GitHub.

Licence

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dict_field_redacter-0.1.2.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dict_field_redacter-0.1.2-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file dict_field_redacter-0.1.2.tar.gz.

File metadata

  • Download URL: dict_field_redacter-0.1.2.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for dict_field_redacter-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4b0bedb32764b34bbdb765c8c92cbe37bc6bac1c8ccb7b89f0ff3da02b545483
MD5 894e59b17c6eb495700511fbe379b705
BLAKE2b-256 e0535e037672b79768f226e1f311e96cc9108d8e99dc34d172e63da5d0083bfb

See more details on using hashes here.

File details

Details for the file dict_field_redacter-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for dict_field_redacter-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2f1054586455a230d750904bd4d4c611532b13bf2d1258c34c3cbf2cf9f9d0ed
MD5 cddb8b18e200d54dc644c51571c6f7ab
BLAKE2b-256 c7fb7d20b6ca6d8c5d204813ad89368c99df9c25a6fad0b0b56d931514493ab2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page