I have a list of unique email addresses - a very simple question. If the email is unique will the output always be unique,
hash('md2', $email);
I have a list of unique email addresses - a very simple question. If the email is unique will the output always be unique,
hash('md2', $email);
Hash functions like MD2 are like the name suggests message digest algorithms they take an arbitrary length input and give a fixed length output. There are bound to exist collisions for unique inputs.
You can use stronger hash functions like SHA-256 where a collision between two strings is highly unlikely compared to MD2. The birthday paradox applies here, so you shouldn't use MDx functions or anything shorter than 256-bit hash functions.
I see you're hashing e-mail addresses. Depending on your system, this can be exploited with a collision. For example, some e-mail providers enable virtual addresses of the form "myname+1@domain.com", "myname+2@domain.com" and so on. An attacker might use that fact to find a collision with a known other e-mail address to get for example the password reset e-mail or something like that.