Does the MD5 algorithm always generate the same output for the same string?
Is using a salt the only to produce different output?
Does the MD5 algorithm always generate the same output for the same string?
Is using a salt the only to produce different output?
Yes, MD5 always outputs the same given the same input. That's how it's used for passwords. You store the hash in the database, then when the user types their password in, it's hashed again and the two hashes are compared.
NOTE: MD5 is not recommended for hashing passwords because it's cryptographically weak. There are more suitable cryptographic hashes available, such as bcrypt. However, historically, it has been used for this purpose.
Yes MD5 is deterministic, and this is considered a desirable characteristic for many applications of message digest functions.
As for using a salt, by that you really mean 'changing the input string in some subtle way' don't you ? And, of course, it is also a desirable characteristic of message digests that they produce (with very high probability) a different digest for a different message.