shorter php cipher than md5? shorter php cipher than md5? php php

shorter php cipher than md5?


maybe this will help you generate a 12 char string that you can pass in a URL, without increasing the risk of collisions

substr(base_convert(md5($string), 16,32), 0, 12);


This is an addition to this answer.

The answer proposes to take the first twelve characters from a 32 character representation of md5. Thus 20 characters of information will be lost - this will result in way more possible collisions.

You can reduce the loss of information by taking the first twelve characters of a 16 character representation (the raw form):

substr(md5($string, true), 0, 12);

This will maintain 75% of the data, whereas the use of the 32 char form only maintains 37.5% of the data.