cryptint

cryptint

cryptint : Encryption functions for int and bigint values

Overview

ID Extension Package Version Category License Language
4450
cryptint
cryptint
1.0.0
UTIL
PostgreSQL
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
See Also
hashlib
shacrypt
pguecc
pgcrypto
gzip
bzip
zstd
http

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
1.0.0
18
17
16
15
14
cryptint -
RPM
PIGSTY
1.0.0
18
17
16
15
14
cryptint_$v -
DEB
PIGSTY
1.0.0
18
17
16
15
14
postgresql-$v-cryptint -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
el8.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
el9.x86_64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
el9.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
el10.x86_64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
el10.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
d12.x86_64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
d12.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
d13.x86_64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
d13.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u22.x86_64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u22.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u24.x86_64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u24.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
Package Version OS ORG SIZE File URL
cryptint_18 1.0.0 el8.x86_64 pigsty 14.0 KiB cryptint_18-1.0.0-1PIGSTY.el8.x86_64.rpm
cryptint_18 1.0.0 el8.aarch64 pigsty 14.2 KiB cryptint_18-1.0.0-1PIGSTY.el8.aarch64.rpm
cryptint_18 1.0.0 el9.x86_64 pigsty 13.6 KiB cryptint_18-1.0.0-1PIGSTY.el9.x86_64.rpm
cryptint_18 1.0.0 el9.aarch64 pigsty 13.6 KiB cryptint_18-1.0.0-1PIGSTY.el9.aarch64.rpm
cryptint_18 1.0.0 el10.x86_64 pigsty 13.6 KiB cryptint_18-1.0.0-1PIGSTY.el10.x86_64.rpm
cryptint_18 1.0.0 el10.aarch64 pigsty 13.7 KiB cryptint_18-1.0.0-1PIGSTY.el10.aarch64.rpm
postgresql-18-cryptint 1.0.0 d12.x86_64 pigsty 13.2 KiB postgresql-18-cryptint_1.0.0-1PIGSTY~bookworm_amd64.deb
postgresql-18-cryptint 1.0.0 d12.aarch64 pigsty 13.5 KiB postgresql-18-cryptint_1.0.0-1PIGSTY~bookworm_arm64.deb
postgresql-18-cryptint 1.0.0 d13.x86_64 pigsty 13.2 KiB postgresql-18-cryptint_1.0.0-1PIGSTY~trixie_amd64.deb
postgresql-18-cryptint 1.0.0 d13.aarch64 pigsty 13.5 KiB postgresql-18-cryptint_1.0.0-1PIGSTY~trixie_arm64.deb
postgresql-18-cryptint 1.0.0 u22.x86_64 pigsty 13.6 KiB postgresql-18-cryptint_1.0.0-1PIGSTY~jammy_amd64.deb
postgresql-18-cryptint 1.0.0 u22.aarch64 pigsty 13.6 KiB postgresql-18-cryptint_1.0.0-1PIGSTY~jammy_arm64.deb
postgresql-18-cryptint 1.0.0 u24.x86_64 pigsty 13.7 KiB postgresql-18-cryptint_1.0.0-1PIGSTY~noble_amd64.deb
postgresql-18-cryptint 1.0.0 u24.aarch64 pigsty 13.8 KiB postgresql-18-cryptint_1.0.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
cryptint_17 1.0.0 el8.x86_64 pigsty 14.0 KiB cryptint_17-1.0.0-1PIGSTY.el8.x86_64.rpm
cryptint_17 1.0.0 el8.aarch64 pigsty 14.2 KiB cryptint_17-1.0.0-1PIGSTY.el8.aarch64.rpm
cryptint_17 1.0.0 el9.x86_64 pigsty 13.6 KiB cryptint_17-1.0.0-1PIGSTY.el9.x86_64.rpm
cryptint_17 1.0.0 el9.aarch64 pigsty 13.6 KiB cryptint_17-1.0.0-1PIGSTY.el9.aarch64.rpm
cryptint_17 1.0.0 el10.x86_64 pigsty 13.6 KiB cryptint_17-1.0.0-1PIGSTY.el10.x86_64.rpm
cryptint_17 1.0.0 el10.aarch64 pigsty 13.7 KiB cryptint_17-1.0.0-1PIGSTY.el10.aarch64.rpm
postgresql-17-cryptint 1.0.0 d12.x86_64 pigsty 13.2 KiB postgresql-17-cryptint_1.0.0-1PIGSTY~bookworm_amd64.deb
postgresql-17-cryptint 1.0.0 d12.aarch64 pigsty 13.4 KiB postgresql-17-cryptint_1.0.0-1PIGSTY~bookworm_arm64.deb
postgresql-17-cryptint 1.0.0 d13.x86_64 pigsty 13.2 KiB postgresql-17-cryptint_1.0.0-1PIGSTY~trixie_amd64.deb
postgresql-17-cryptint 1.0.0 d13.aarch64 pigsty 13.4 KiB postgresql-17-cryptint_1.0.0-1PIGSTY~trixie_arm64.deb
postgresql-17-cryptint 1.0.0 u22.x86_64 pigsty 13.8 KiB postgresql-17-cryptint_1.0.0-1PIGSTY~jammy_amd64.deb
postgresql-17-cryptint 1.0.0 u22.aarch64 pigsty 13.9 KiB postgresql-17-cryptint_1.0.0-1PIGSTY~jammy_arm64.deb
postgresql-17-cryptint 1.0.0 u24.x86_64 pigsty 13.7 KiB postgresql-17-cryptint_1.0.0-1PIGSTY~noble_amd64.deb
postgresql-17-cryptint 1.0.0 u24.aarch64 pigsty 13.8 KiB postgresql-17-cryptint_1.0.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
cryptint_16 1.0.0 el8.x86_64 pigsty 14.0 KiB cryptint_16-1.0.0-1PIGSTY.el8.x86_64.rpm
cryptint_16 1.0.0 el8.aarch64 pigsty 14.2 KiB cryptint_16-1.0.0-1PIGSTY.el8.aarch64.rpm
cryptint_16 1.0.0 el9.x86_64 pigsty 13.6 KiB cryptint_16-1.0.0-1PIGSTY.el9.x86_64.rpm
cryptint_16 1.0.0 el9.aarch64 pigsty 13.6 KiB cryptint_16-1.0.0-1PIGSTY.el9.aarch64.rpm
cryptint_16 1.0.0 el10.x86_64 pigsty 13.6 KiB cryptint_16-1.0.0-1PIGSTY.el10.x86_64.rpm
cryptint_16 1.0.0 el10.aarch64 pigsty 13.7 KiB cryptint_16-1.0.0-1PIGSTY.el10.aarch64.rpm
postgresql-16-cryptint 1.0.0 d12.x86_64 pigsty 13.2 KiB postgresql-16-cryptint_1.0.0-1PIGSTY~bookworm_amd64.deb
postgresql-16-cryptint 1.0.0 d12.aarch64 pigsty 13.4 KiB postgresql-16-cryptint_1.0.0-1PIGSTY~bookworm_arm64.deb
postgresql-16-cryptint 1.0.0 d13.x86_64 pigsty 13.2 KiB postgresql-16-cryptint_1.0.0-1PIGSTY~trixie_amd64.deb
postgresql-16-cryptint 1.0.0 d13.aarch64 pigsty 13.5 KiB postgresql-16-cryptint_1.0.0-1PIGSTY~trixie_arm64.deb
postgresql-16-cryptint 1.0.0 u22.x86_64 pigsty 13.8 KiB postgresql-16-cryptint_1.0.0-1PIGSTY~jammy_amd64.deb
postgresql-16-cryptint 1.0.0 u22.aarch64 pigsty 13.9 KiB postgresql-16-cryptint_1.0.0-1PIGSTY~jammy_arm64.deb
postgresql-16-cryptint 1.0.0 u24.x86_64 pigsty 13.7 KiB postgresql-16-cryptint_1.0.0-1PIGSTY~noble_amd64.deb
postgresql-16-cryptint 1.0.0 u24.aarch64 pigsty 13.8 KiB postgresql-16-cryptint_1.0.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
cryptint_15 1.0.0 el8.x86_64 pigsty 14.0 KiB cryptint_15-1.0.0-1PIGSTY.el8.x86_64.rpm
cryptint_15 1.0.0 el8.aarch64 pigsty 14.3 KiB cryptint_15-1.0.0-1PIGSTY.el8.aarch64.rpm
cryptint_15 1.0.0 el9.x86_64 pigsty 13.8 KiB cryptint_15-1.0.0-1PIGSTY.el9.x86_64.rpm
cryptint_15 1.0.0 el9.aarch64 pigsty 13.9 KiB cryptint_15-1.0.0-1PIGSTY.el9.aarch64.rpm
cryptint_15 1.0.0 el10.x86_64 pigsty 13.8 KiB cryptint_15-1.0.0-1PIGSTY.el10.x86_64.rpm
cryptint_15 1.0.0 el10.aarch64 pigsty 14.0 KiB cryptint_15-1.0.0-1PIGSTY.el10.aarch64.rpm
postgresql-15-cryptint 1.0.0 d12.x86_64 pigsty 13.3 KiB postgresql-15-cryptint_1.0.0-1PIGSTY~bookworm_amd64.deb
postgresql-15-cryptint 1.0.0 d12.aarch64 pigsty 13.5 KiB postgresql-15-cryptint_1.0.0-1PIGSTY~bookworm_arm64.deb
postgresql-15-cryptint 1.0.0 d13.x86_64 pigsty 13.3 KiB postgresql-15-cryptint_1.0.0-1PIGSTY~trixie_amd64.deb
postgresql-15-cryptint 1.0.0 d13.aarch64 pigsty 13.5 KiB postgresql-15-cryptint_1.0.0-1PIGSTY~trixie_arm64.deb
postgresql-15-cryptint 1.0.0 u22.x86_64 pigsty 13.9 KiB postgresql-15-cryptint_1.0.0-1PIGSTY~jammy_amd64.deb
postgresql-15-cryptint 1.0.0 u22.aarch64 pigsty 14.1 KiB postgresql-15-cryptint_1.0.0-1PIGSTY~jammy_arm64.deb
postgresql-15-cryptint 1.0.0 u24.x86_64 pigsty 13.8 KiB postgresql-15-cryptint_1.0.0-1PIGSTY~noble_amd64.deb
postgresql-15-cryptint 1.0.0 u24.aarch64 pigsty 14.0 KiB postgresql-15-cryptint_1.0.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
cryptint_14 1.0.0 el8.x86_64 pigsty 14.0 KiB cryptint_14-1.0.0-1PIGSTY.el8.x86_64.rpm
cryptint_14 1.0.0 el8.aarch64 pigsty 14.3 KiB cryptint_14-1.0.0-1PIGSTY.el8.aarch64.rpm
cryptint_14 1.0.0 el9.x86_64 pigsty 13.8 KiB cryptint_14-1.0.0-1PIGSTY.el9.x86_64.rpm
cryptint_14 1.0.0 el9.aarch64 pigsty 13.9 KiB cryptint_14-1.0.0-1PIGSTY.el9.aarch64.rpm
cryptint_14 1.0.0 el10.x86_64 pigsty 13.8 KiB cryptint_14-1.0.0-1PIGSTY.el10.x86_64.rpm
cryptint_14 1.0.0 el10.aarch64 pigsty 14.0 KiB cryptint_14-1.0.0-1PIGSTY.el10.aarch64.rpm
postgresql-14-cryptint 1.0.0 d12.x86_64 pigsty 13.2 KiB postgresql-14-cryptint_1.0.0-1PIGSTY~bookworm_amd64.deb
postgresql-14-cryptint 1.0.0 d12.aarch64 pigsty 13.5 KiB postgresql-14-cryptint_1.0.0-1PIGSTY~bookworm_arm64.deb
postgresql-14-cryptint 1.0.0 d13.x86_64 pigsty 13.2 KiB postgresql-14-cryptint_1.0.0-1PIGSTY~trixie_amd64.deb
postgresql-14-cryptint 1.0.0 d13.aarch64 pigsty 13.5 KiB postgresql-14-cryptint_1.0.0-1PIGSTY~trixie_arm64.deb
postgresql-14-cryptint 1.0.0 u22.x86_64 pigsty 13.9 KiB postgresql-14-cryptint_1.0.0-1PIGSTY~jammy_amd64.deb
postgresql-14-cryptint 1.0.0 u22.aarch64 pigsty 14.0 KiB postgresql-14-cryptint_1.0.0-1PIGSTY~jammy_arm64.deb
postgresql-14-cryptint 1.0.0 u24.x86_64 pigsty 13.8 KiB postgresql-14-cryptint_1.0.0-1PIGSTY~noble_amd64.deb
postgresql-14-cryptint 1.0.0 u24.aarch64 pigsty 14.0 KiB postgresql-14-cryptint_1.0.0-1PIGSTY~noble_arm64.deb

Source

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

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

Create this extension with:

CREATE EXTENSION cryptint;

Usage

cryptint: Encrypt and decrypt integers with SKIP32 and XTEA

SKIP32 (32-bit integer encryption)

Block cipher with 24 rounds based on Skipjack. Encrypts 32-bit values with an 80-bit (10-byte) key.

SELECT skip32_encrypt(42, '\x00010203040506070809'::bytea);
-- encrypted int4

SELECT skip32_decrypt(175586429, '\x00010203040506070809'::bytea);
-- 0

Roundtrip example:

SELECT i, skip32_encrypt(i, '\x00010203040506070809'::bytea) AS encrypted,
       skip32_decrypt(skip32_encrypt(i, '\x00010203040506070809'::bytea), '\x00010203040506070809'::bytea) AS decrypted
FROM generate_series(-3, 3) AS i;

XTEA (64-bit integer encryption)

Block cipher with 64 rounds. Encrypts 64-bit values with a 128-bit (16-byte) key.

SELECT xtea_encrypt(42::bigint, '\x000102030405060708090a0b0c0d0e0f'::bytea);
-- encrypted bigint

SELECT xtea_decrypt(103200416458222088::bigint, '\x000102030405060708090a0b0c0d0e0f'::bytea);
-- 1

Functions Reference

Function Description
skip32_encrypt(int, bytea) Encrypt int4 with 10-byte key
skip32_decrypt(int, bytea) Decrypt int4 with 10-byte key
xtea_encrypt(bigint, bytea) Encrypt bigint with 16-byte key
xtea_decrypt(bigint, bytea) Decrypt bigint with 16-byte key
Last updated on