Why are md5 passwords hashed differently?

Solution 1:

They all have a different salt. A unique salt is chosen each time, as salts should never be reused. Using a unique salt for each password makes them resistant to rainbow table attacks.

Solution 2:

Indeed if you provide the salt to the command line you always get the same result.

$ echo 'helloworld' | openssl passwd -1 -stdin -salt my-salt
$1$my-salt$S/PsLSioHR8ffN8bpIzsk/
$ echo 'helloworld' | openssl passwd -1 -stdin -salt my-salt
$1$my-salt$S/PsLSioHR8ffN8bpIzsk/
$ echo 'helloworld' | openssl passwd -1 -stdin -salt my-salt
$1$my-salt$S/PsLSioHR8ffN8bpIzsk/