You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+116-4Lines changed: 116 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,14 +79,126 @@ stash setup --proxy
79
79
80
80
# Start the containers
81
81
docker compose up
82
+
```
83
+
84
+
This will start a PostgreSQL database on `localhost:5432`, and CipherStash Proxy on `localhost:6432`.
85
+
There's an example table called `users` that you can use to start inserting and querying encrypted data with.
86
+
87
+
> [!NOTE]
88
+
> In this example table we've chosen users' email, date of birth, and salary as examples of the kind of sensitive data that you might want to protect with encryption.
89
+
90
+
### Step 1: Insert and read some data <aid='getting-started-step-1'></a>
91
+
92
+
Now let's connect to the Proxy via `psql` and run some queries:
Update the data we inserted in [Step 1](#getting-started-step-1), and read it back:
137
+
138
+
```sql
139
+
UPDATE users SET encrypted_dob ='1978-02-01'WHERE encrypted_email ='alice@cipherstash.com';
140
+
141
+
SELECT encrypted_dob FROM users WHERE encrypted_email ='alice@cipherstash.com';
142
+
```
143
+
144
+
In the `UPDATE` statement, the `=` comparison operation in the `WHERE` clause is evaluated against **encrypted** data.
145
+
In the `SELECT` statement, the `encrypted_email` value is transparently encrypted by Proxy, and compared in the database against the stored encrypted email value.
146
+
In the `SELECT` statement, the `SELECT` returns `1978-02-01`.
147
+
148
+
Back on the `psql` session connected directly to the database, verify the data is encrypted:
149
+
150
+
```sql
151
+
SELECT encrypted_email, encrypted_dob, encrypted_salary FROM users;
152
+
```
153
+
154
+
This `SELECT` shows the raw encrypted data — no plaintext to see.
155
+
156
+
### Step 3: Search encrypted data with a `WHERE` clause <aid='getting-started-step-3'></a>
Insert more records via Proxy, and search by salary:
165
+
166
+
```sql
167
+
INSERT INTO users (encrypted_email, encrypted_dob, encrypted_salary) VALUES ('bob@cipherstash.com', '1991-03-06', '10');
168
+
INSERT INTO users (encrypted_email, encrypted_dob, encrypted_salary) VALUES ('carol@cipherstash.com', '2005-12-30', '1000');
169
+
170
+
SELECT encrypted_email, encrypted_dob, encrypted_salary FROM users WHERE encrypted_salary <=100;
171
+
```
172
+
173
+
In the `INSERT` statement, the salary value is transparently encrypted by Proxy, and stored in the database in encrypted form.
174
+
In the `SELECT` statement, the `encrypted_salary` value is transparently encrypted and compared in the database against the stored encrypted salary value.
175
+
In the `SELECT` statement, the `<=` comparison operation in the `WHERE` clause is evaluated against **encrypted** data.
176
+
In the `SELECT` statement, the `SELECT` returns `alice` and `bob`, but not `carol`.
177
+
178
+
Finally, query `users` by date:
179
+
180
+
```sql
181
+
SELECT encrypted_email, encrypted_dob, encrypted_salary FROM users WHERE encrypted_dob >'2000-01-01' ;
182
+
```
183
+
184
+
The `encrypted_dob` value is transparently encrypted by Proxy, and compared in the database against the stored encrypted date value.
185
+
The `>` comparison operation is evaluated against **encrypted** data.
186
+
The `SELECT` will only return `carol`.
187
+
188
+
Back on the `psql` session connected directly to the database, verify the data is encrypted:
189
+
190
+
```sql
191
+
SELECT encrypted_email, encrypted_dob, encrypted_salary FROM users;
192
+
```
193
+
194
+
This `SELECT` shows the raw encrypted data, no plaintext to see.
195
+
196
+
This demonstrates the power of CipherStash Proxy:
197
+
198
+
- Completely transparent encryption of sensitive data in PostgreSQL
199
+
- All data remains searchable, while being protected with non-deterministic AES-256-GCM encryption
200
+
- Zero changes required to your application's database queries
201
+
90
202
## How-to
91
203
92
204
This section contains how-to documentation for installing, configuring, and running CipherStash Proxy.
0 commit comments