The problem sounds pretty common but somehow I can't find something which helps me with that...
I feel like I'm lacking fundamental hashing and encryption knowledge.
Problem
Suppose that I have a phone number which is (hopefully unique and) used as ID.
But I don't want to use my private number as ID in public interfaces.
What I need is a solution which obfuscates a string one way but still keeping the uniqueness so when someone else uses the algorithm he will get the same ID.
Solution (?)
Is there a hash algorithm which guarantees uniqueness when the input does not exceed the hashed output length but remains still (almost) impossible to reverse.
What about using a fixed public key RSA encryption? The output should be unique but the attacker would have to break a single key decrypt all numbers. Sounds like a bad idea...
Update (based on answer)
Obviously I'm searching for a cryptographic hash algorithm with a low collision probability.
Now (that I have caught some sleep and) thought that through there are some more facts I can think of:
- I have to deal with collisions anyway. When I use a phone number as ID without further verification then anyony could state "this one is mine".
- Rainbow tables will always be a problem. Since there's a manageable amount of phone numbers and everyone should be able to generate the hash from the phone number (I can't even use a secret salt). My only possibility is to use a intensive algorithm and a salt which makes the rainbow table unique I think.
With that being said: I can decide on using a hash. This way no one can tell immediately (without attacking it) which phone number is used. That seems to be the whole point.