https://github.com/davidb/json-simple-obfuscator
a tool to partially hide json value (using unsecure pseudonimize / obfuscate algo)
https://github.com/davidb/json-simple-obfuscator
Last synced: 3 months ago
JSON representation
a tool to partially hide json value (using unsecure pseudonimize / obfuscate algo)
- Host: GitHub
- URL: https://github.com/davidb/json-simple-obfuscator
- Owner: davidB
- License: cc0-1.0
- Created: 2025-05-23T12:20:12.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2026-03-04T19:40:54.000Z (3 months ago)
- Last Synced: 2026-03-05T01:43:19.559Z (3 months ago)
- Language: Rust
- Size: 86.9 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# json-simple-obfuscator
A tool to partially hide json value (using unsecure pseudonimize / obfuscate algo).
## Goals / Use-cases
- Hide sensitive values into samples json used for test, demo
- Hide values also when present as part of an other string
- Idempotent and constant: `apply(a.json) == apply(apply(apply(.... (apply(a.json)))))`, so it could be used as part of pre-commit hook, build stage,...
- **DO NOT** use it to encrypt secrets,...
## Usage
```bash
❯ json-simple-obfuscator file1.json file2.json
◇ Obfuscated 2 files
│
└ Done!
```
```bash
❯ json-simple-obfuscator -h
A tool to partially hide json value (using unsecure pseudonimize / obfuscate algo).
Usage: json-simple-obfuscator [FILE]...
Arguments:
[FILE]... path of files to obfuscate
Options:
-h, --help Print help
-V, --version Print version
```
### Install
Download the binary from the [release page](https://github.com/davidB/json-simple-obfuscator/releases).
Via shell script
```bash
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/davidB/json-simple-obfuscator/releases/download/0.2.0/json-simple-obfuscator-installer.sh | sh
```
Via power shell script
```powershell
powershell -ExecutionPolicy Bypass -c "irm https://github.com/davidB/json-simple-obfuscator/releases/download/0.2.0/json-simple-obfuscator-installer.ps1 | iex"
```
Via homebrew
```bash
brew install brew install davidB/tap/json-simple-obfuscator
```
Via cargo
```bash
cargo install json-simple-obfuscator
```
Via mise
```toml
[tools]
"ubi:davidB/json-simple-obfuscator" = "latest"
```
## A simple algorithm
```json
{
"a": "Hello",
"id": 123456,
"details": {
"user": "johnD",
"name": "John Doe",
"url": "http://example.com/item/123456"
}
}
```
becomes
```json
{
"a": "Hello",
"id": 111111,
"details": {
"user": "aaaaA",
"name": "Aaaa Aaa",
"url": "http://example.com/item/111111"
}
}
```
1. Collect values (string or number) of "sensitive" fields.
the "sensitive" fields are field named(in lowercase): `id`, `_id`, `*token`, `*password`, `*secret`, `user`, `*name`, `
2. For each value, compute the replacement value
- for number, replace every digit by `1` (preserve the number of digit, dot & comma)
- for string, replace lowercase by `a` and uppercase by `A`, digit by `1` (preserve other caracteres: )
3. Search collected values, and replace by the computed replacement into the json as text (to preserve structure, order, comment for json5/jsonc, ...)
## Possible feature (on-demand)
Feedback, PR and feature request are welcomes. By example:
- Option to provide the list of sensitive fields
- Option to exclude some field name form the sensitive pattern
- Option to provide fixed replacement (using a lookup table)
- Option to compute replacement for different alphabet, emoji, ...
- Option to use random replacement (and break the idempotency)