Suppose the hash function used is an ideal one-way function. Then you can view your output as a "random oracle" , its output values are in a finite range of values (2 ^ 128 for MD5).
Now, what happens if you apply the hash several times? The output will remain in the same range (2 ^ 128). It looks like you say, "Guess my random number!" Twenty times, each time thinking about a new number - this does not make it more difficult or easier to guess. There is no “more random" than random. This is not a perfect analogy, but I think it helps illustrate the problem.
Given the forced password entry, your scheme does not add any security at all. Worse, the only thing you could “accomplish” is to loosen security by introducing some ability to reuse the hash function. This is unlikely, but at least it guaranteed that you probably won’t win anything.
So why is still not all lost with this approach? This is because others have expressed the view that there are thousands of iterations instead of two dozen. Why is it good, slowing down the algorithm? This is because most cybercriminals will try to gain access using a dictionary (or a rainbow table using frequently used passwords, hoping that one of your users is careless enough to use one of them (I'm to blame, at least Ubuntu told me about installation). But, on the other hand, it is inhumane for your users to remember, say 30 random characters.
That's why we need some form of compromise between easy-to-remember passwords, but at the same time make it so that attackers can guess them. There are two common practices: salt and process slowdown, using many iterations of some function instead of one iteration. PKCS # 5 is a good example to learn.
In your case, using MD5 20,000 instead of 20 times will slow down attackers using the dictionary significantly down, because each of their input passwords will have to go through the usual procedure of withdrawing 20,000 times in order to be useful as an attack. formatting as shown above.
But why is salt use even better? Because even if you use a hash 20,000 times, a resourceful attacker can pre-compute a large database of passwords by hashing each one 20,000 times, effectively creating a custom rainbow table specifically designed for your application. By doing this, they could easily attack your application or any other application using your scheme. To do this, you also need to create a high cost for the password in order to make such rainbow tables inappropriate.
If you want to be safe, use something like PBKDF2 shown in PKCS # 5.