0

I'm searching for a encrypt method that receives an int variable and outputs exactly 11 hexadecimal digits.

I'm starting on a existing application, that already has a database of more than 130.000 registers, each one with his own 11 hex-digits code. The old algorhythm only generated random 11 hex-digits, with no information codified. The new algorhythm should encrypt the id of a table (int data type, 4 bytes) into a 11 hex-dig. In case of collisions (with old registers, that should be kept), I'm thinking of using a counter as "salt", combine it with the id I want to encrypt, and repeat incrementing the counter until it does not collide.

I have searched a lot these days about encrypt methods, symmetric and assymmetric methods, but all of them gives a result bigger than my limitation of 44 bits/11 hex-digits. I've also found that a so short cyphertext is not secure, but these data are not so critical and I can't change this limitation of the application, so it's fine.

Because I need to validate these codes in the future (check if decrypted id is present on table, when datetime information indicates that it's a new-algorhythm code), I cannot take only a part of the cyphertext (for example, using something like "LEFT(code, 11)").

The application runs on PHP/MySQL. Is there a encryption method that parametrizes the length of output? Or should I develop a custom encryption? In this case, any suggestion for avoiding collisions?

Thanks in advance.

6
  • Hash plus lookup table?
    – schroeder
    Dec 10, 2014 at 18:33
  • Thanks for the hint, @schroeder. As English is not my language, I'm taking some time to research about possible solutions I find. For hashing, wouldn't I lose some information? I mean, it's different of an encrypt, that can be reversible.
    – Ulisses
    Dec 10, 2014 at 19:47
  • It sounds like hashing would be more useful than encrypting for that.
    – user49075
    Dec 10, 2014 at 20:36
  • You are correct that hashing is not reversible, which is why you would need a lookup table to relate the hash to the data you need to relate it to. If you are limited to such a small set of characters, this is likely your best option.
    – schroeder
    Dec 10, 2014 at 21:10
  • I'm not finding good examples, it seems the term "lookup table" is more often used in image processing, both in English and Portuguese. Any suggestion of a good example I could read, or at least, another words I could use in searches?
    – Ulisses
    Dec 12, 2014 at 15:26

0

You must log in to answer this question.

Browse other questions tagged .