Generate unique ID from multiple values with fault tolerance

Posted by ojreadmore on Stack Overflow See other posts from Stack Overflow or by ojreadmore
Published on 2010-12-06T09:12:37Z Indexed on 2012/10/11 15:37 UTC
Read the original article Hit count: 155

Given some values, I'd like to make a (pretty darn) unique result.

$unique1 = generate(array('ab034', '981kja7261', '381jkfa0', 'vzcvqdx2993883i3ifja8', '0plnmjfys'));
//now $unique1 == "sqef3452y";

I also need something that's pretty close to return the same result. In this case, 20% of the values is missing.

$unique2 = generate(array('ab034', '981kja7261', '381jkfa0', 'vzcvqdx2993883i3ifja8'));
//also $unique2 == "sqef3452y";

I'm not sure where to begin with such an algorithm but I have some assumptions.

  1. I assume that the more values given, the more accurate the resulting ID – in other words, using 20 values is better than 5.
  2. I also assume that a confidence factor can be calculated and adjusted.

What would be nice to have is a weight factor where one can say 'value 1 is more important than value 3'. This would require a multidimensional array for input instead of one dimension.

I just mashed on the keyboard for these values, but in practice they may be short or long alpha numeric values.

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about language-agnostic