Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is md5 an injective function?

Is md5 hashing algorithm an injective function? meaning that it will generate a unique output for any given input?

If not, is there some other similar hashing algorithm that is injective?

like image 385
Yasser1984 Avatar asked Nov 27 '22 11:11

Yasser1984


1 Answers

No, MD5 has collision vunerabilities. Other hash functions such as SHA-1 also have hash collisions, although it is much less likely than MD5.

An injective hashing function is also known as a perfect hash function. Perfect hash functions do exist, but there are certain requirements or information you will need to know about the input data before you can know that your hash is perfect.

You could look at CMPH for information on creating a perfect hash function.

like image 118
cmbuckley Avatar answered Mar 04 '23 11:03

cmbuckley