Introduction M.E.D.

A Data Masking, Encryption, and Decryption CLI tools powered-by Rust

Wei Huang
Dev Genius

--

The most recent Hot topic is the A.I., chatGPT, etc.

It will significantly impact the I.T. industry, and we all hope this progress and innovation will continue on the right and positive impact moving forward to benefit human society.

If you look into the A.I., the fundamental keys are the Data, Compute Power, and Models.

How we can ensure data security and get the most value of the data will be the critical consideration and the most crucial topic in the industry.

Key features

  1. Simplicity
    Easy to use, including the easy to install/set up and configurable.
  2. Extendability
    Extendable to different integration patterns, such as standard API or integration-focused SDK.
  3. Audibility
    Data manipulation SHALL be traceable, ensuring the overall operation can be auditable end to end, which is part of the enterprise readiness.
  4. Built with Rust
    Memory safety and Fearless Concurrency, with a performance out of the box.

A tour of M.E.D.

Ready to give it a try? Let's start with the installation.

Installation

Currently, there are 2 ways to install the M.E.D:

Installation with cargo

## install the package via cargo
cargo install med_cli
## navigate to the binary location
cd $HOME/.cargo/bin

Installation with packages

Navigate to the release page in Github.

And depends on your current OS, download the package; I’m also working on the submission to different package managers for download.

M.E.D. in action

Let’s say you have a directory containing some csv files and have the name, email, and phone fields you want to mask.

Prepare configuration file

If you are using the cargo installation, you must prepare the config files; this configuration file applies to both csv and json.

### conf.yaml example
mask_symbols: "#####" # mask symbols
fields: # list of the cols/fields you want to mask
- name
- email
- phone

If you download the packages, a demo folder will contain the demo configuration files and data.

Execution

Let’s get into the execution with the parameters.

  1. There are three critical Modes for med [mask, encrypt, decrypt].
  2. We must provide the key and standard in the encrypt or decrypt modes [des64, aes128, aes 192, or aes256].
  3. The default output-dir will be in the same dir named output if you are not specific to the custom dir.

Example as below

### mask the csv files in folders
### -f is the files location
### -c is the configuration yaml file location
### -w is the concurrent worker number
med mask -f demo/data/csv -c demo/conf/conf_csv.yaml -w 3

### encryption the files will need
### 1. provide key(-k)
### 2. standard(-s)
med encrypt -f demo/data/csv -c demo/conf/conf_csv.yaml -w 8 -k SERCET_KEY -s des64
mask csv result — Credit by Author

Please note for simplicity, the program will automatically set up the Audit SQLite database, and every execution will be recorded to it, which you can find the location in the execution INFO.

Audit Table

For the Audit capabilities, I’m leveraging SQLite, and the decision made is best on the “simplicity” requirement, which:

SQLite is a cross-platform DBMS that can run on all platforms, including macOS, Windows, and Linux etc. SQLite doesn’t require any configuration. It needs no setup or administration.

This means the database can be set up during the runtime and ready to use once the application is installed/run in the runtime machine (cross-platform).

And the metadata are ensuring following the Entreprise level Audit base standard, mainly focusing on capturing, Who, When, Where(which machine), do what, and status, etc.

During the program execution, the metrics struct will keep updated with the runtime, capturing the runtime metrics for the audit update.

The metadata and migration are available here.

You can use any database GUI tools to review the audit table; the audit db location will be different depending on your OS.

audit table location — Credit by Author

Full user guide layout

$ med --help
A simple to use, enterprise ready, rust powered data masking/encryption/decription cli tool

Usage: med <MODE> --file <FILE> [OPTIONS]

Arguments:
<MODE>
What mode to run the program in
Possible values:
- mask: Mask the data by *
- encrypt: Encrypt the data with provided KEY
- decrypt: Decrypt the data with provided KEY

Options:
-t, --type <TYPE> type of file we will process, available option [csv, json] [default: csv]
-k, --key <KEY> key for Encrypt and Decrypt the file.
-s, --standard <STANDARD> set the Encrypt and Decrypt standard
Possible values:
- des64: DES standard 64
- aes128: AES standard 128
- aes192: AES standard 192
- aes256: AES standard 256
-f, --file <FILE> file path for the
-c, --config <CONFIG> Sets a custom config yml path [default: conf.yaml]
-o, --output <OUTPUT> Sets a file/directory path for output [default: output]
-d, --debug <DEBUG> Sets debug flag [possible values: true, false]
-w, --worker <WORKER> Sets work flag
-h, --help Print help (see a summary with '-h')
-V, --version Print version

Final words

This project has been open-sourced; please kindly test/try it out.

  1. Welcome to Comments/suggestions/support.
  2. Also, welcome to keep building/contributing with me.

And meanwhile, if you like it, please give the Star(⭐️) for the repos. :)

Thank you for your reading. And if you like my week and build and learn, please follow me with Medium.

--

--