
Format-Preserving Permutation Replaces Uniqueness Checks for Duplicate-Free Data Masking in PostgreSQL
A team developing a data masking service for PostgreSQL and SQL Server has replaced random or hash-based replacement with keyed permutations built on Feistel networks. The approach guarantees uniqueness within each format class without checking the target table, preserves referential integrity across tables, and remains fully deterministic and reproducible. Values are decomposed into fixed, variable, and checksum fields; only the variable portion is permuted inside its numeric range using an eight-round Feistel construction with AES as the round function, followed by cycle-walking when the result exceeds the original domain size. The method supports mixed-radix classes such as IBAN, SNILS, IMEI, and email addresses while keeping control digits valid. Because the construction is non-standard, the authors explicitly warn that it provides pseudonymization rather than irreversible anonymization.
HabrNov 2, 2026Translated from Russian