I'm looking for the name of a certain kind of algorithm, which I think should have a name.
The algorithm is the one that figures out the shortest possible string in order to make it identifiably unique from the rest.
Like, in JS, a function given an array like this one:
[ '1c625b142483629db0a8063cfe5cd418e897154c',
'28d9bf0ecac10311507b339e5d1324412d25cc3e',
'4f3a202a34016cbdf1fc05c3efaaa06f72d3faa3',
'2080d7f2b572196343695a7c60a6f3c6b747246c',
'1903250de6c2a59e6c53dfa907188f2a7204ce76',
'f8227a5a0e8eeea2fd7b47588d95d05755d0eb5b',
'86aed9bd91eee88bb17382fe278a5fdc6f16d583' ]
Would return something like:
[ '1c',
'28',
'4',
'20',
'19',
'f',
'8' ]
Notice how all of the strings it returned are the first characters in the long hashes, just shortened in order to return only what is necessary to make them different from each other.
I'm going to be using this for matching a hash to a value. I'm making a todo app and I decided to use hashing in order to edit and/or remove values. So the user would refer to the todo item by it's hash, but I don't want to give the user a super long hash, only what the system needs to know which one the user is referring to.
So what would this kind of algorithm be called, if it does have a name?
Any help or clues are appreciated. :)
EDIT:
Seems like there is a discussion of how I'm going to use this. I just want to clear up that I am not going to use this to store stuff. The full hash is going to be used as the key for the todo task, the shortened hash (a.k.a. shortest unique prefix) is just for the UI. My question, which is what the name is, has been answered by @source.rar and @Paul, I'm now looking into the implementations. Will accept answer shortly...
EDIT 2:
All right. Being a JS newbie I spent a TON of time trying to figure it out by myself and couldn't, in the end my friend came along and gave me the following solution: https://gist.github.com/BruceCaldwell/70e53a456fd858bb03cc
He did, however, say it was not perfect and could probably do with some refactoring, but that's up to me to figure out. ;)