cryptint
Encryption functions for int and bigint values
Repository
dverite/cryptint
https://github.com/dverite/cryptint
Source
cryptint-1.0.0.tar.gz
cryptint-1.0.0.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
cryptint | 1.0.0 | UTIL | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4450 | cryptint | No | Yes | No | Yes | No | Yes | - |
| Related | hashlib shacrypt pguecc pgcrypto gzip bzip zstd http |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0.0 | 1817161514 | cryptint | - |
| RPM | PIGSTY | 1.0.0 | 1817161514 | cryptint_$v | - |
| DEB | PIGSTY | 1.0.0 | 1817161514 | postgresql-$v-cryptint | - |
Build
You can build the RPM / DEB packages for cryptint using pig build:
pig build pkg cryptint # build RPM / DEB packages
Install
You can install cryptint 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 cryptint; # Install for current active PG version
pig ext install -y cryptint -v 18 # PG 18
pig ext install -y cryptint -v 17 # PG 17
pig ext install -y cryptint -v 16 # PG 16
pig ext install -y cryptint -v 15 # PG 15
pig ext install -y cryptint -v 14 # PG 14
dnf install -y cryptint_18 # PG 18
dnf install -y cryptint_17 # PG 17
dnf install -y cryptint_16 # PG 16
dnf install -y cryptint_15 # PG 15
dnf install -y cryptint_14 # PG 14
apt install -y postgresql-18-cryptint # PG 18
apt install -y postgresql-17-cryptint # PG 17
apt install -y postgresql-16-cryptint # PG 16
apt install -y postgresql-15-cryptint # PG 15
apt install -y postgresql-14-cryptint # PG 14
Create Extension:
CREATE EXTENSION cryptint;
Usage
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 |
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.