Advertisement

Encryption, Primary Keys and Infinity

By on

Click to learn more about author David Schlesinger.

A certain area of cyber security involves encryption. This necessarily includes a good passphrase, modular math and a lot of scrambling.  Good encryption produces a coded message that appears like a series of random numbers.

You see, in a real series of random numbers. There is infinite entropy. (Stay with me for a minute) – Entropy is an indication of how random a number series is. A perfect string of random numbers is a series of ones and zeros (this how computers see it) where there is no way to guess as to which the next number in a series will be: a one or zero. (Stay with me here. The tech part is almost over.)  This is infinite entropy.

No matter how long a series of ones and zeros are examined, we could discern no pattern. The chance that the next digit will be a one or zero is always 50 /50. Without any pattern, there is no information content in the encrypted message.  It exists only as an abstracts in the realm of higher mathematics

Whew – that’s over!

Now here is why a random number is best for a primary key. When you put intelligence into key, perhaps using the first four digits for location, and then next two for status, you have reduced the length of the unique key. In a 10-character key, you would have reduced the unique part to six characters.

Eventually, new locations and new status levels will be added so that the intelligence part of the key will be insufficient. Here you’ll have either to make the key longer or simply stop using the intelligence you’ve put in.

Putting intelligence in the primary key is thinking that is left over from the early days of computing. In those days, people had to be able to look at keys manually and make decisions. Having intelligence in a key is essentially useless in today’s systems. A proper field in the record should be used for attributes.

You want the system to be expandable and capable of integration with other systems, and for this often need unique, primary keys of significant length.   Putting intelligence in a primary key will always come back to bite the company later. If you need the old intelligence than may use a combined concatenated key connecting to the true random number.

Remember, if there is no intelligence at all in a primary key, there will never, ever, ever, be any reason to change it: not to meet new conditions, not to add new locations, or new status, or new laws, or new districts.  Like a random string of encrypted digits, it can never be wrong.

The secret to never having to modify your primary keys is to make them truly random. Randomness is a powerful tool.  Never having to change a primary key gives you freedom from change.

A Trick You Might Want to Use…or Not

Let us say for the sake of conversation that you have a DBMS with keys that are all mixed together due to merging older systems. The primary keys have intelligence in them but different keys have different intelligence.  At first glance, you might think it is better to just start again with new keys, and this may indeed be the best answer.

But there is an alternative.  It involves encryption.  When you encrypt anything the result looks random, acts random, and feels random, but in reality, it is not.  Its actual content is currently elsewhere in the realm of higher mathematics, but it exists as a potential.  This is why we can decrypt it later and get the actual message.

Back to your keys.  You certainly could give the records new keys and keep the old one as a reference attribute.  But if you wanted to, you could encrypt all the old keys.  You could even use the same password for all of them, and you would get a series of random numbers of significant length.  These keys will have no order, no intelligence, and act just like random numbers.  Except that you can, if you ever need to, decrypt them years later and find the actual original key without having to carry that around as another attribute. The original key is carried in the realm of higher mathematics

Cool huh?

Leave a Reply