# Can md5 be used for encrypting data?

I know that md5 shouldn't be used for password hashing because of collisions and possibility of making dictionary attacks e.g. using rainbow tables. But what about other uses? Can I use md5 for encrypting data?

Say, attacker gains access to database where sensitive data was stored using md5. He wants to know just this data that was hashed, not another data that gives this hash. Can he do it?

I know that there are better cryptographic hash functions so don't suggest to use them if md5 is enough.

The proof of the encryption scheme usually follows the following type of reduction. Assuming $\mathsf{X}$ is secure under the $\mathsf{Y}$ model, the encryption scheme is secure under the $\mathcal{A}$ attack. Here $\mathsf{X}$ is your assumptions, say the (collision, preimage, second-preimage, target collision, enhanced target collision) resistance property of the hash function family or computational assumptions like $\mathsf{DDH, DH}$ etc; $\mathsf{Y}$ can be standard model, random oracle model, ideal cipher model, uniform complexity model, non-uniform complexity model, etc; and $\mathcal{A}$ can be chosen plaintext, chosen ciphertext, known plaintext or known ciphertext attack.
Now in all the possible scenario, since you can find second preimage or collision for MD5 easily, $\mathsf{X}$ does not hold true. Hence, the implication is dangling. Recall that enhanced target collision resistance and target collision resistance are weaker notion of security than collision resistance and hence they will give you even less security guarantee.