5.4. Encryption via Tables

The DES Public Key Encryption algorithm (FIPS 42-2) is driven by tables of permutations on a 64-bit block of data. I do not want to go into the algorithms, since they typically involve low-level bit fiddling for which SQL was never intended, but encryption is a class of functions for which they try to make it hard to find an inverse function.

A very simple, but surprisingly good, encryption is to use a table of integers between 0 and 7 (or 0 and 15 for Unicode) to determine how far to circular shift an ASCII character. Circular shift is a machine-level that shifts the bits right (or left) for (n) positions as if they were in a circle, so no bits are lost. For example, RgtRotate(‘01110111’, 3) = ‘11101110’.

CREATE TABLE ...

Get Joe Celko's Thinking in Sets: Auxiliary, Temporal, and Virtual Tables in SQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.