Sample operations and tasks
This section provides instructions to complete some common pgcrypto tasks.Connect to PostgreSQL
Perform the following steps to connect to PostgreSQL with PGAdmin:To add a server connection, perform the following steps:
- Right-click Servers in the browser panel.
- Select Register > Server.
Enter the following configuration details:
- On the General tab: Enter a name for the connection
- In the Connection tab, fill in:
- Host: Server IP or hostname (use “localhost” for local connections)
- Port: 5432 (default)
- Username: Enter
postgres(or your specific username) - Password: Your password
Create a database
Perform the following steps to create a new database:Enable pgcrypto
The pgcrypto extension enables you to use cryptographic functions like pgp_sym_encrypt, pgp_sym_decrypt, crypt, and others in your PostgreSQL instance. Perform the following steps to enable pgcrypto:To enable the pgcrypto extension, in the query window, run the following command:
CREATE EXTENSION pgcrypto;Encrypt at the column level
Run the following SQL query to create a sample table and encrypt all data stored in the pgp_sym_encrypt column:View unencrypted data
To view the information in the table unencrypted, without column-level encryption applied, run the following command:View encrypted data
To see the table with column-level encrypted data, run the following command:View encrypted data in hex
To see column-level encrypted data in binary or hexadecimal format, run the following command:Find the DB files
Perform the following steps to see where your physical database files are stored:Add a new path rule inside your PostgreSQL service on the CryptoHub
The following steps apply the Futurex TDP solution on these files to ensure they are encrypted on the disk, with the symmetric key stored on the Cryptohub appliance:Add an Advanced Path Rule to where the database files are stored for the TestDB you created. For example:
C:\PostgreSQL\data\base\16387\**This rule encrypts all unstructured data in the folder.
The files in the directory
C:\PostgreSQL\data\base\16387 (or similar directories) include the actual data of your PostgreSQL database. These files store the contents of tables, indexes, and other database objects in a binary format optimized for the PostgreSQL storage engine.
