Skip to content

pgspeck

Encrypt and decrypt 32-bit and 48-bit integer blocks with the Speck symmetric cipher

pgspeck · Encrypt and decrypt 32-bit and 48-bit integer blocks with the Speck symmetric cipher

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100043pgspeckpgspeck1.0SECMITC

PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18

Usage

Sources:

pgspeck version 1.0 provides deterministic Speck block-cipher permutations for turning sequential integer values into less obvious integer sequences. The 32-bit functions use the low 32 bits of the plaintext and a 64-bit key; the 48-bit functions use the low 48 bits of the plaintext and two nonzero 48-bit key components.

Verify a reversible mapping

CREATE EXTENSION pgspeck;

SELECT pgspeck_encrypt32(42, 123456789);

SELECT pgspeck_decrypt32(
    pgspeck_encrypt32(42, 123456789),
    123456789
);

Use this only as reversible identifier obfuscation. Small deterministic blocks reveal repeated inputs, provide no nonce or authentication, and do not protect integrity; wrapping or truncation also requires careful domain analysis. Keys passed in SQL can leak through function definitions, logs, monitoring, query text, or role access. Do not use pgspeck for passwords, personal data, secrets, access tokens, or modern application encryption. Keep authorization independent of the obscured identifier and use a reviewed authenticated-encryption design whenever confidentiality matters.

Table reader