Skip to content

Latest commit

ย 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

MongoDB data masking โ€” Python examples

This repository contains the code samples for the How to implement data masking in MongoDB tutorial. It covers four data masking techniques:

  • view-based masking
  • aggregation pipeline masking
  • static data masking
  • tokenization

The techniques are implemented in Python using a MongoDB Atlas free tier cluster.

Each technique has its own Python file. Before you run any file, replace the <USERNAME>, <PASSWORD>, and <HOST> placeholders in the connection string with your Atlas credentials and cluster hostname.

Clone the repository

Run the following command to clone the repository to your machine:

git clone https://github.com/<your-username>/mongodb-masking.git

Set up your environment

Navigate into the project folder:

cd mongodb-masking

Create and activate a virtual environment:

python -m venv venv
source venv/bin/activate

On Windows, activate the virtual environment with:

venv\Scripts\activate

Install the required packages:

python -m pip install pymongo faker

Replace the connection string placeholders

In each file, replace <USERNAME>, <PASSWORD>, and <HOST> with your Atlas credentials and cluster hostname. You can find your connection string in the Atlas UI under Database > Connect > Drivers.

Run the files

Each file demonstrates one masking technique. Run them individually with the following commands:

python view_masking.py
python aggregation_masking.py
python static_masking.py
python tokenization.py

Refer to the tutorial for a full explanation of what each script does and when to use each technique.

About

This repository contains the code samples for the How to implement data masking in MongoDB tutorial. It covers four data masking techniques โ€” view-based masking, aggregation pipeline masking, static data masking, and tokenization โ€” implemented in Python using a MongoDB Atlas free tier cluster.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages