Skip to content

pg_enigma

Encrypted postgres data type

pg_enigma · Encrypted postgres data type

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
7090pg_enigmapg_enigma0.5.0SECMITRust
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d--NoYesNoYesnono

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY0.5.019 18 17 16 15pg_enigma-
RPMPIGSTY0.5.019 18 17 16 15pg_enigma_$v-
DEBPIGSTY0.5.019 18 17 16 15postgresql-$v-enigma-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
el8.aarch64N/APIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
el9.x86_64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
el9.aarch64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
el10.x86_64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
el10.aarch64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
d12.x86_64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
d12.aarch64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
d13.x86_64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
d13.aarch64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
u22.x86_64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
u22.aarch64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
u24.x86_64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
u24.aarch64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
u26.x86_64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
u26.aarch64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
PackageVersionOSORGSIZEFile URL
pg_enigma_180.5.0el8.x86_64pigsty3.4 MiBpg_enigma_18-0.5.0-3PIGSTY.el8.x86_64.rpm
pg_enigma_180.5.0el8.aarch64pigsty3.0 MiBpg_enigma_18-0.5.0-3PIGSTY.el8.aarch64.rpm
pg_enigma_180.5.0el9.x86_64pigsty3.8 MiBpg_enigma_18-0.5.0-4PGSTY.el9.x86_64.rpm
pg_enigma_180.5.0el9.aarch64pigsty3.5 MiBpg_enigma_18-0.5.0-4PGSTY.el9.aarch64.rpm
pg_enigma_180.5.0el10.x86_64pigsty3.8 MiBpg_enigma_18-0.5.0-4PGSTY.el10.x86_64.rpm
pg_enigma_180.5.0el10.aarch64pigsty3.5 MiBpg_enigma_18-0.5.0-4PGSTY.el10.aarch64.rpm
postgresql-18-enigma0.5.0d12.x86_64pigsty2.6 MiBpostgresql-18-enigma_0.5.0-4PGSTY~bookworm_amd64.deb
postgresql-18-enigma0.5.0d12.aarch64pigsty2.3 MiBpostgresql-18-enigma_0.5.0-4PGSTY~bookworm_arm64.deb
postgresql-18-enigma0.5.0d13.x86_64pigsty2.6 MiBpostgresql-18-enigma_0.5.0-4PGSTY~trixie_amd64.deb
postgresql-18-enigma0.5.0d13.aarch64pigsty2.3 MiBpostgresql-18-enigma_0.5.0-4PGSTY~trixie_arm64.deb
postgresql-18-enigma0.5.0u22.x86_64pigsty2.9 MiBpostgresql-18-enigma_0.5.0-4PGSTY~jammy_amd64.deb
postgresql-18-enigma0.5.0u22.aarch64pigsty2.7 MiBpostgresql-18-enigma_0.5.0-4PGSTY~jammy_arm64.deb
postgresql-18-enigma0.5.0u24.x86_64pigsty2.9 MiBpostgresql-18-enigma_0.5.0-4PGSTY~noble_amd64.deb
postgresql-18-enigma0.5.0u24.aarch64pigsty2.7 MiBpostgresql-18-enigma_0.5.0-4PGSTY~noble_arm64.deb
postgresql-18-enigma0.5.0u26.x86_64pigsty2.9 MiBpostgresql-18-enigma_0.5.0-4PGSTY~resolute_amd64.deb
postgresql-18-enigma0.5.0u26.aarch64pigsty2.7 MiBpostgresql-18-enigma_0.5.0-4PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_enigma_170.5.0el8.x86_64pigsty3.4 MiBpg_enigma_17-0.5.0-3PIGSTY.el8.x86_64.rpm
pg_enigma_170.5.0el8.aarch64pigsty3.0 MiBpg_enigma_17-0.5.0-3PIGSTY.el8.aarch64.rpm
pg_enigma_170.5.0el9.x86_64pigsty3.8 MiBpg_enigma_17-0.5.0-4PGSTY.el9.x86_64.rpm
pg_enigma_170.5.0el9.aarch64pigsty3.5 MiBpg_enigma_17-0.5.0-4PGSTY.el9.aarch64.rpm
pg_enigma_170.5.0el10.x86_64pigsty3.8 MiBpg_enigma_17-0.5.0-4PGSTY.el10.x86_64.rpm
pg_enigma_170.5.0el10.aarch64pigsty3.5 MiBpg_enigma_17-0.5.0-4PGSTY.el10.aarch64.rpm
postgresql-17-enigma0.5.0d12.x86_64pigsty2.6 MiBpostgresql-17-enigma_0.5.0-4PGSTY~bookworm_amd64.deb
postgresql-17-enigma0.5.0d12.aarch64pigsty2.3 MiBpostgresql-17-enigma_0.5.0-4PGSTY~bookworm_arm64.deb
postgresql-17-enigma0.5.0d13.x86_64pigsty2.6 MiBpostgresql-17-enigma_0.5.0-4PGSTY~trixie_amd64.deb
postgresql-17-enigma0.5.0d13.aarch64pigsty2.3 MiBpostgresql-17-enigma_0.5.0-4PGSTY~trixie_arm64.deb
postgresql-17-enigma0.5.0u22.x86_64pigsty2.9 MiBpostgresql-17-enigma_0.5.0-4PGSTY~jammy_amd64.deb
postgresql-17-enigma0.5.0u22.aarch64pigsty2.7 MiBpostgresql-17-enigma_0.5.0-4PGSTY~jammy_arm64.deb
postgresql-17-enigma0.5.0u24.x86_64pigsty2.9 MiBpostgresql-17-enigma_0.5.0-4PGSTY~noble_amd64.deb
postgresql-17-enigma0.5.0u24.aarch64pigsty2.7 MiBpostgresql-17-enigma_0.5.0-4PGSTY~noble_arm64.deb
postgresql-17-enigma0.5.0u26.x86_64pigsty2.9 MiBpostgresql-17-enigma_0.5.0-4PGSTY~resolute_amd64.deb
postgresql-17-enigma0.5.0u26.aarch64pigsty2.7 MiBpostgresql-17-enigma_0.5.0-4PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_enigma_160.5.0el8.x86_64pigsty3.4 MiBpg_enigma_16-0.5.0-3PIGSTY.el8.x86_64.rpm
pg_enigma_160.5.0el8.aarch64pigsty3.0 MiBpg_enigma_16-0.5.0-3PIGSTY.el8.aarch64.rpm
pg_enigma_160.5.0el9.x86_64pigsty3.8 MiBpg_enigma_16-0.5.0-4PGSTY.el9.x86_64.rpm
pg_enigma_160.5.0el9.aarch64pigsty3.5 MiBpg_enigma_16-0.5.0-4PGSTY.el9.aarch64.rpm
pg_enigma_160.5.0el10.x86_64pigsty3.8 MiBpg_enigma_16-0.5.0-4PGSTY.el10.x86_64.rpm
pg_enigma_160.5.0el10.aarch64pigsty3.5 MiBpg_enigma_16-0.5.0-4PGSTY.el10.aarch64.rpm
postgresql-16-enigma0.5.0d12.x86_64pigsty2.6 MiBpostgresql-16-enigma_0.5.0-4PGSTY~bookworm_amd64.deb
postgresql-16-enigma0.5.0d12.aarch64pigsty2.3 MiBpostgresql-16-enigma_0.5.0-4PGSTY~bookworm_arm64.deb
postgresql-16-enigma0.5.0d13.x86_64pigsty2.6 MiBpostgresql-16-enigma_0.5.0-4PGSTY~trixie_amd64.deb
postgresql-16-enigma0.5.0d13.aarch64pigsty2.3 MiBpostgresql-16-enigma_0.5.0-4PGSTY~trixie_arm64.deb
postgresql-16-enigma0.5.0u22.x86_64pigsty2.9 MiBpostgresql-16-enigma_0.5.0-4PGSTY~jammy_amd64.deb
postgresql-16-enigma0.5.0u22.aarch64pigsty2.7 MiBpostgresql-16-enigma_0.5.0-4PGSTY~jammy_arm64.deb
postgresql-16-enigma0.5.0u24.x86_64pigsty2.9 MiBpostgresql-16-enigma_0.5.0-4PGSTY~noble_amd64.deb
postgresql-16-enigma0.5.0u24.aarch64pigsty2.7 MiBpostgresql-16-enigma_0.5.0-4PGSTY~noble_arm64.deb
postgresql-16-enigma0.5.0u26.x86_64pigsty2.9 MiBpostgresql-16-enigma_0.5.0-4PGSTY~resolute_amd64.deb
postgresql-16-enigma0.5.0u26.aarch64pigsty2.7 MiBpostgresql-16-enigma_0.5.0-4PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_enigma_150.5.0el8.x86_64pigsty3.4 MiBpg_enigma_15-0.5.0-3PIGSTY.el8.x86_64.rpm
pg_enigma_150.5.0el8.aarch64pigsty3.0 MiBpg_enigma_15-0.5.0-3PIGSTY.el8.aarch64.rpm
pg_enigma_150.5.0el9.x86_64pigsty3.7 MiBpg_enigma_15-0.5.0-4PGSTY.el9.x86_64.rpm
pg_enigma_150.5.0el9.aarch64pigsty3.5 MiBpg_enigma_15-0.5.0-4PGSTY.el9.aarch64.rpm
pg_enigma_150.5.0el10.x86_64pigsty3.7 MiBpg_enigma_15-0.5.0-4PGSTY.el10.x86_64.rpm
pg_enigma_150.5.0el10.aarch64pigsty3.5 MiBpg_enigma_15-0.5.0-4PGSTY.el10.aarch64.rpm
postgresql-15-enigma0.5.0d12.x86_64pigsty2.6 MiBpostgresql-15-enigma_0.5.0-4PGSTY~bookworm_amd64.deb
postgresql-15-enigma0.5.0d12.aarch64pigsty2.3 MiBpostgresql-15-enigma_0.5.0-4PGSTY~bookworm_arm64.deb
postgresql-15-enigma0.5.0d13.x86_64pigsty2.6 MiBpostgresql-15-enigma_0.5.0-4PGSTY~trixie_amd64.deb
postgresql-15-enigma0.5.0d13.aarch64pigsty2.3 MiBpostgresql-15-enigma_0.5.0-4PGSTY~trixie_arm64.deb
postgresql-15-enigma0.5.0u22.x86_64pigsty2.9 MiBpostgresql-15-enigma_0.5.0-4PGSTY~jammy_amd64.deb
postgresql-15-enigma0.5.0u22.aarch64pigsty2.7 MiBpostgresql-15-enigma_0.5.0-4PGSTY~jammy_arm64.deb
postgresql-15-enigma0.5.0u24.x86_64pigsty2.9 MiBpostgresql-15-enigma_0.5.0-4PGSTY~noble_amd64.deb
postgresql-15-enigma0.5.0u24.aarch64pigsty2.7 MiBpostgresql-15-enigma_0.5.0-4PGSTY~noble_arm64.deb
postgresql-15-enigma0.5.0u26.x86_64pigsty2.9 MiBpostgresql-15-enigma_0.5.0-4PGSTY~resolute_amd64.deb
postgresql-15-enigma0.5.0u26.aarch64pigsty2.7 MiBpostgresql-15-enigma_0.5.0-4PGSTY~resolute_arm64.deb

Source

pig build pkg pg_enigma;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_enigma;		# install by package name

pig install pg_enigma -v 19;   # install for PG 19
pig install pg_enigma -v 18;   # install for PG 18
pig install pg_enigma -v 17;   # install for PG 17
pig install pg_enigma -v 16;   # install for PG 16
pig install pg_enigma -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION pg_enigma;

Usage

pg_enigma: Encrypted data type for PostgreSQL using PGP and RSA keys

pg_enigma provides an Enigma encrypted data type for PostgreSQL that encrypts data at rest using PGP or OpenSSL RSA keys. Data is stored encrypted and only decrypted when the private key is loaded into memory.

CREATE EXTENSION IF NOT EXISTS pg_enigma;

PGP Key Encryption

-- Create a table with an encrypted column (key slot 2)
CREATE TABLE test_pgp (
    id SERIAL,
    val Enigma(2)
);

-- Load the public key for encryption
SELECT set_public_key_from_file(2, '/path/to/public-key.asc');

-- Insert data (automatically encrypted with the public key)
INSERT INTO test_pgp (val) VALUES ('A secret value'::Text);

-- Without private key, SELECT returns encrypted PGP message
SELECT * FROM test_pgp;

-- Load private key to enable decryption
SELECT set_private_key_from_file(2, '/path/to/private-key.asc', 'passphrase');

-- Now SELECT returns decrypted plaintext
SELECT * FROM test_pgp;
-- id |      val
-- ----+----------------
--   1 | A secret value

-- Remove private key from memory
SELECT forget_private_key(2);
-- Subsequent SELECTs return encrypted data again

RSA Key Encryption

CREATE TABLE test_rsa (
    id SERIAL,
    val Enigma(3)
);

SELECT set_public_key_from_file(3, '/path/to/alice_public.pem');
INSERT INTO test_rsa (val) VALUES ('Another secret value'::Text);

SELECT set_private_key_from_file(3, '/path/to/alice_private.pem', 'passphrase');
SELECT * FROM test_rsa;

SELECT forget_private_key(3);

Functions

FunctionDescription
set_public_key_from_file(slot, path)Load a public key for encryption
set_private_key_from_file(slot, path, passphrase)Load a private key for decryption
forget_private_key(slot)Remove private key from memory

Table reader