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 |
Source
pig build pkg cryptint; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall 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 14Create this extension with:
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);
-- 0Roundtrip 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);
-- 1Functions 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