marimba
marimba

Reputation: 3136

Unique, human readable ID from class properties

I would like to create a unique, human readable ID from several class properties, for example:

Class A contains property c,d,e
Class B contains property f,g

So one ID would represent

c=1
d=2
e=3
f=4
g=5

while another ID would represent

c=7
d=3
e=4
f=0
g=11

For arguments sake, properties are only integers (EDIT: in a range from 0 to 1000), while in reality they could also be floats and strings actually.

I am looking for a way to combine these values into a short, human readable ID. Additionally, I would like to be able to reconstruct the properties from the ID. Also, if possible, small differences in properties should result in small differences in the ID as well.

Here is an example what I would consider small & human readable: H5RT33

Are there any algorithms for something like that?

EDIT: I wrote down the ID example while anticipating a question like "what is human readable for you?". I found that difficult to describe - a MD5, for example, would be not, while a real word like "Tree" is not necessary. So the ID given is somewhat in the middle, but I didn't mean to restrict it to 6 characters, or only uppercase letters and numbers.

Also, I talked about integers while I really meant "integers in a range from 0-1000".

Upvotes: 2

Views: 215

Answers (1)

rici
rici

Reputation: 241671

You want an invertible transformation (a bijection), which means that the information content of both original and transform are the same. A six-character alphanumeric code using only capital letters, as in H5RT33 has 366 possible values; in other words, it has 6 * log236 = 31.1 bits of information. Five (32-bit) integers, on the other hand, contain 5 * 32 = 180 bits, which is quite a bit more (unless, of course, the integers have a restricted range). And you say you'd also like to encode floating point numbers and strings, which contain quite a bit more information.

So on strictly information-theoretic grounds, I think you're going to have a hard time fulfilling all of your requirements.

Upvotes: 3

Related Questions