shacrypt

shacrypt

shacrypt : Implements SHA256-CRYPT and SHA512-CRYPT password encryption schemes

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
4440
shacrypt
shacrypt
1.1
UTIL
PostgreSQL
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
See Also
hashlib
xxhash
cryptint
pguecc
pgcrypto
gzip
bzip
zstd

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
1.1
18
17
16
15
14
shacrypt-
RPM
PIGSTY
1.1
18
17
16
15
14
shacrypt_$v-
DEB
PIGSTY
1.1
18
17
16
15
14
postgresql-$v-shacrypt-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
el8.aarch64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
el9.x86_64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
el9.aarch64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
el10.x86_64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
el10.aarch64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
d12.x86_64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
d12.aarch64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
d13.x86_64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
d13.aarch64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
u22.x86_64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
u22.aarch64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
u24.x86_64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
u24.aarch64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1

Source

pig build pkg shacrypt;		# 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 shacrypt;		# install via package name, for the active PG version

pig install shacrypt -v 18;   # install for PG 18
pig install shacrypt -v 17;   # install for PG 17
pig install shacrypt -v 16;   # install for PG 16
pig install shacrypt -v 15;   # install for PG 15
pig install shacrypt -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION shacrypt;

Usage

shacrypt: SHA-crypt password hashing for PostgreSQL

Generate SHA256-CRYPT and SHA512-CRYPT password hashes per the SHA-crypt specification.

Functions

sha256_crypt(key text, salt text) RETURNS text

SELECT sha256_crypt('clearpassword', 'somesalt');
-- $5$somesalt$l3SlbI688JBlRS9RWFC1EwZLNJqfQKcrF3yhcbc7ffA

With custom rounds:

SELECT sha256_crypt('clearpassword', '$5$rounds=10000$somesalt');
-- $5$rounds=10000$somesalt$OekH6Tu7EOJIAvxKJ4Ko4bG0DxgO83gZODJLTTjXJi5

sha512_crypt(key text, salt text) RETURNS text

SELECT sha512_crypt('clearpassword', 'somesalt');
-- $6$somesalt$dDcgWMHOtvHI6qT/Khi3uaaxXN6v4N9bnOeWFl/Y6K3pzxi/...

Salt Format

  • Simple salt: 'somesalt'
  • With algorithm prefix: '$5$somesalt' (SHA-256) or '$6$somesalt' (SHA-512)
  • With custom rounds: '$5$rounds=10000$somesalt'
Last updated on