Skip to main content

Library to anonymize JSON objects by creating placeholders for keys and values, while generating a reversible mapping to restore afterwards

Project description

Prompt-Horizon

Prompt-Horizon is a Python library that enables developers to anonymize JSON objects by creating placeholders for keys and values, while generating a reversible mapping to restore the original JSON data. The purpose of this library is to facilitate data sharing while preserving privacy and allowing for the de-anonymization of the data when required.

Note: I had the idea for this library when I was trying to find a way to obfuscate data objects such as JSON to include them as contextual information in prompts (hence the name).

Prompt-Horizon is not designed to specifically identify and anonymize PII (personally identifiable information) or other sensitive data within the JSON objects.


Installation

pip install prompt-horizon

Usage

Anonymize JSON


from prompt_horizon import anonymize

input_json = {
    "name": "John",
    "age": 30,
    "city": "New York",
    "favorites": ["pizza", "basketball"]
}

#This line will return the anonymized JSON object and the mapping object.
anonymized_json, map_object = anonymize(input_json)

Original JSON:

{
    "name": "John",
    "age": 30,
    "city": "New York",
    "favorites": ["pizza", "basketball"]
}

Anonymized JSON:

{
    "a1": "a2",
    "a3": "a4",
    "a5": "a6",
    "a7": ["a8", "a9"]
}

input and output file handling is supported

from prompt_horizon import anonymize

#This line will read the JSON data from "input.json", anonymize it, and save the anonymized JSON to "anonymized.json".
anonymized_json, map_object = anonymize("input.json", output_file_path="anonymized.json")

De-anonymize JSON


from prompt_horizon import de_anonymize

#This line will return the de-anonymized JSON object, which should be the same as the original input JSON.
deanonymized_json = de_anonymize(anonymized_json, map_object=map_object)

input and output files are supported

from prompt_horizon import de_anonymize

#This will read the anonymized JSON data from "anonymized.json", the mapping object from "map_file.json", de-anonymize the JSON data, and save the de-anonymized JSON to "deanonymized.json".
deanonymized_json = de_anonymize("anonymized.json", map_file_path="map_file.json", output_file_path="deanonymized.json")

Saving and loading the map


License

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

prompt-horizon-0.1.2.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

prompt_horizon-0.1.2-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file prompt-horizon-0.1.2.tar.gz.

File metadata

  • Download URL: prompt-horizon-0.1.2.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for prompt-horizon-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a53c296f5f3ca91c2d4d188a03ae09c7cc222dba81f2760328a2f82bfe5e27e9
MD5 c4e5509dde199bed59539d4339f7c24d
BLAKE2b-256 49bc8f07ce960bbbfbed312ada581922a825021d52c424ef957f3e96034ec118

See more details on using hashes here.

File details

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

File metadata

  • Download URL: prompt_horizon-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for prompt_horizon-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d15c80430449236046a2f1dcb99ff959bf277ddd4d5d24e35d2a732fc9aec5ab
MD5 c73a75eed8c21b3a69b1de6e350a1bc8
BLAKE2b-256 3b996afdd809befaa4ffeee9fcdfb4ca3bfb28b07f169460d8a35a24be4911ee

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