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 DictFieldRedacter
import json
fields_to_redact = ["email", "password", "secret", "cvv", "pin", "number"]
redacter = DictFieldRedacter(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 DictFieldRedacter
import json
fields_to_redact = ["email", "password", "secret", "cvv", "pin", "number"]
redacter = DictFieldRedacter(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.3.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.3-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dict_field_redacter-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 10d80be8d896c8f85926d5c43a5cafc20cd6a9645e54bee3c73b7cc7bc713187
MD5 5a55b1826129eb998c1e2a65ab9d730d
BLAKE2b-256 8f75d6db1cf6fd101efc1ddba1eec03cdbcb3b4e30db5ebff0660502d0e0a2a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dict_field_redacter-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f693da6f502577a4ef449a0632728e3f8ebd4d39df5f49e99952ac014645e5fb
MD5 fa8fb0323d04d7115e6bae967ba39d54
BLAKE2b-256 5dc3cb6607cdd40da99077b9e2d8bfe461418306492fe2d73c6de2784203a397

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