# objfuscate

> Redacts Javascript objects

Latest version **0.2.0** (published 2016-01-20) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install objfuscate
pnpm add objfuscate
yarn add objfuscate
bun add objfuscate
```

Provides the command `objfuscate`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2016-01-20 |
| First published | 2016-01-20 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Thomas Rueckstiess |
| Maintainers | rueckstiess |

## Links

- npm: https://www.npmjs.com/package/objfuscate
- Repository: https://github.com/mongodb-js/objfuscate
- Homepage: http://mongodb-js.github.io/objfuscate
- Issues: https://github.com/mongodb-js/objfuscate/issues
- npm.io page: https://npm.io/package/objfuscate

## Dependencies (8)

- [clui](https://npm.io/package/clui.md) ^0.3.1
- [async](https://npm.io/package/async.md) ^1.2.1
- [debug](https://npm.io/package/debug.md) ^2.2.0
- [docopt](https://npm.io/package/docopt.md) ^0.6.2
- [lodash](https://npm.io/package/lodash.md) ^3.10.1
- [cli-color](https://npm.io/package/cli-color.md) ^1.0.0
- [event-stream](https://npm.io/package/event-stream.md) ^3.3.2
- [mongodb-extended-json](https://npm.io/package/mongodb-extended-json.md) ^1.6.1

## Recent versions

- 0.2.0 (latest) — 2016-01-20
- 0.1.0 — 2016-01-20
- 0.0.1 — 2016-01-20

## README

# Objfuscate
[![build status](https://secure.travis-ci.org/mongodb-js/objfuscate.png)](http://travis-ci.org/mongodb-js/objfuscate)

Redacts JSON object values recursively, and keys if desired.

## Installation

```
npm install -g objfuscate
```

## Usage

```
Usage:
   objfuscate [options] <jsonfile>
   objfuscate --version
   objfuscate -h | --help

Options:
   -h, --help           Print this help screen
   -k, --include-keys   Obfuscate keys as well
   -p, --pretty         Print the result with line breaks and indentation
```

#### Use with a JSON file

```
objfuscate ./sensitive.json
```

This will write the obfuscated JSON to stdout. In most cases, you will want to store the result in another file, which you can do like so:

```
objfuscate ./sensitive.json > obfuscated.json
```

Note: The file can be a single JSON object, a newline-delimited list of JSON objects (for example when using `mongoexport` **without** the `--jsonArray` option) or an array of JSON objects (for example when using `mongoexport` **with** the `--jsonArray` option). The output format matches the input format.

#### Use with JSON string

```
objfuscate '{"my": "secret"}'
```

Note: The JSON string must be wrapped in single quotes and you need to write proper JSON, which includes double quotes around key names and strings.

## Value Obfuscation
Currently, only the following values are replaced:
- Strings
- Numbers

Values use a cache so that each value is replaced with the same random value, which is created when a particular value is first encountered. This ensures that the dataset has the same cardinality as the original.

## Key Obfuscation
To replace object keys as well, use the `-k` or `--include-keys` option like so:

```
objfuscate -k ./paranoid.json
objfuscate --include-keys ./paranoid.json
```

They key cache is the same as the value cache (see above). A key named `"foo"` is replaced with the same new string as the value `"foo"`.

## Pretty output

_(Only applicable if the input file was a single JSON object, or an array of JSON objects. Newline-delimited JSON objects are not prettified.)_

Per default, the output is written compressed into a single line without whitespace. If you want the output to be nicely formatted with line breaks, whitespace and indentations, use the `-p` or `--pretty` option.

```
objfuscate --pretty ./documents.json > pretty-obfuscated.json
```

## License
Apache 2.0

---
_Source: https://npm.io/package/objfuscate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
