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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dict_field_redacter-0.1.1.tar.gz.
File metadata
- Download URL: dict_field_redacter-0.1.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59011a2380e3dc627225d5d608beb4b97e9a338f5de2a03702d3bb36ba617ee6
|
|
| MD5 |
ca751c834659779496effb61dffadfbe
|
|
| BLAKE2b-256 |
db04d6a3864b4ce158d03a2a6f8daeef1bb7d67d52118e59c7ed40319ea49f9f
|
File details
Details for the file dict_field_redacter-0.1.1-py3-none-any.whl.
File metadata
- Download URL: dict_field_redacter-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8587c33f82240d2df0db594f2a91982c76c65621d281f24bedf9f53de689aced
|
|
| MD5 |
05f6b73aa3089911c937fa4d93db032c
|
|
| BLAKE2b-256 |
2ba0b8b9fa9d290dedda2be08d85122a05a604dc759c4504affd10759eb8d676
|