shacrypt
Implements SHA256-CRYPT and SHA512-CRYPT password encryption schemes
Repository
dverite/postgres-shacrypt
https://github.com/dverite/postgres-shacrypt
Source
postgres_shacrypt-1.1.tar.gz
postgres_shacrypt-1.1.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
shacrypt | 1.1 | UTIL | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4440 | shacrypt | No | Yes | No | Yes | No | Yes | - |
| Related | hashlib xxhash cryptint pguecc pgcrypto gzip bzip zstd |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.1 | 1817161514 | shacrypt | - |
| RPM | PIGSTY | 1.1 | 1817161514 | shacrypt_$v | - |
| DEB | PIGSTY | 1.1 | 1817161514 | postgresql-$v-shacrypt | - |
Build
You can build the RPM / DEB packages for shacrypt using pig build:
pig build pkg shacrypt # build RPM / DEB packages
Install
You can install shacrypt directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install shacrypt; # Install for current active PG version
pig ext install -y shacrypt -v 18 # PG 18
pig ext install -y shacrypt -v 17 # PG 17
pig ext install -y shacrypt -v 16 # PG 16
pig ext install -y shacrypt -v 15 # PG 15
pig ext install -y shacrypt -v 14 # PG 14
dnf install -y shacrypt_18 # PG 18
dnf install -y shacrypt_17 # PG 17
dnf install -y shacrypt_16 # PG 16
dnf install -y shacrypt_15 # PG 15
dnf install -y shacrypt_14 # PG 14
apt install -y postgresql-18-shacrypt # PG 18
apt install -y postgresql-17-shacrypt # PG 17
apt install -y postgresql-16-shacrypt # PG 16
apt install -y postgresql-15-shacrypt # PG 15
apt install -y postgresql-14-shacrypt # PG 14
Create Extension:
CREATE EXTENSION shacrypt;
Usage
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'
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.