Skip to content

chkpass

data type for auto-encrypted passwords

chkpass · data type for auto-encrypted passwords

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
3920chkpasschkpass1.0TYPEPostgreSQLC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-rNoYesNoYesyesno

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY1.019 18 17 16 15chkpass-
RPMPIGSTY1.019 18 17 16 15chkpass_$v-
DEBPIGSTY1.019 18 17 16 15postgresql-$v-chkpass-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el8.aarch64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el9.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el9.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el10.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el10.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d12.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d12.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d13.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d13.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u22.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u22.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u24.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u24.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u26.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u26.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0

Source

pig build pkg chkpass;		# 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 chkpass;		# install by package name

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

Create this extension with:

CREATE EXTENSION chkpass;

Usage

chkpass: auto-encrypted password data type

The chkpass extension provides a data type for storing encrypted passwords. Originally bundled with PostgreSQL (removed in PG 11), this is a standalone version for modern PostgreSQL.

CREATE EXTENSION chkpass;

Data Type

The chkpass type automatically encrypts passwords using Unix crypt() on input and stores only the encrypted form.

CREATE TABLE accounts (
    username text PRIMARY KEY,
    password chkpass
);

INSERT INTO accounts VALUES ('admin', 'mysecretpassword');

Operators

The = operator checks a plaintext password against the stored encrypted value:

SELECT * FROM accounts WHERE password = 'mysecretpassword';
-- Returns the matching row if the password is correct

Behavior

  • Passwords are automatically encrypted on input – the plaintext is never stored
  • Output displays the encrypted hash, not the original password
  • Comparison with = encrypts the right-hand operand and compares hashes
  • Uses the standard Unix crypt() function for encryption

Table reader