This is a sample project that showcase how to use CypherStash to encrypt your Postgres columns.
You can use the following SQL commands to create the database and the table:
CREATE DATABASE my_database;
CREATE TABLE customer_data (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
phone_number VARCHAR(255) NOT NULL,
__name_encrypted text,
__name_ore text,
__name_match integer[],
__name_unique text,
__email_encrypted text,
__email_ore text,
__email_match integer[],
__email_unique text
);node populate_data.jsYou should see an output indicating that the records have been added to your database. The output should look similar to the following
…output omitted…
30 sample records inserted
Data population completed.Note : Replace
<your_postgres_host>with your PostgreSQL server's hostname or IP address, and<your_database_name>,<your_postgres_username>,<your_postgres_password>with your PostgreSQL database name, username and password, respectively. Also, make sure to replaceyour_postgres_portwith your port number.
Make sure that you have docker running, open your terminal or command prompt and run the Tandem image
docker-compose upFrom your docker desktop dashboard you should see your Tandem image running
Note :
YOUR_DATABASE_PORT,YOUR_DATABASE_NAME,YOUR_DATABASE_USERNAME,YOUR_DATABASE_PASSWORD,YOUR_CIPHERSTASH_WORKSPACE_ID,YOUR_CIPHERSTASH_CLIENT_ID,YOUR_CIPHERSTASH_KEY, andYOUR_CIPHERSTASH_ACCESS_KEYshould be replaced with your actual configuration data.
To run the application from your terminal or command prompt:
node app.jsTo get all users run the following command
curl --request GET 'http://localhost:3000/users'To encrypt data, run the following command:
curl --request POST 'http://localhost:3000/encrypt-data'Author : Lucien Chemaly