To prevent dictionary attacks on password hashes, one common technique is salting the hash.
Option A: Hashing the password twice is not a solution to prevent dictionary attacks. It is a technique called key stretching that makes brute-force attacks slower, but it does not prevent dictionary attacks.
Option B: Encrypting the password using the private key is not a solution to prevent dictionary attacks. Encryption is reversible, and an attacker with the private key can easily obtain the original password.
Option C: Using an encryption algorithm you wrote yourself is not a solution to prevent dictionary attacks. It is not recommended to invent your own encryption algorithm because it can have vulnerabilities that attackers can exploit.
Option D: Salting the hash is a technique that involves adding a random string of characters to the password before hashing. The salt is unique for each password and makes it difficult for an attacker to use precomputed hash tables (rainbow tables) to find the original password. Therefore, it is an effective method to prevent dictionary attacks.
Therefore, the correct answer is:
The Answer is: D