To prevent dictionary attacks on password hashes, we can use a technique called "salting." A salt is a random string of characters that is added to a password before it is hashed. This adds an additional layer of complexity to the hash, making it more difficult for an attacker to use a pre-computed dictionary of hashes to crack passwords.
Now, let's go through each option and explain why it is right or wrong:
A. Encrypting the password using the private key: This option is incorrect. Encryption and hashing are two different techniques. Encryption is a two-way process that can be reversed using a key, while hashing is a one-way process that cannot be reversed. Also, using a private key to encrypt the password would not prevent dictionary attacks.
B. Hashing the password twice: This option is incorrect. Hashing the password twice does not provide any additional security against dictionary attacks. In fact, it can create a vulnerability known as "hash collision," where two different passwords can produce the same hash.
C. Use an encryption algorithm you wrote yourself so no one knows how it works: This option is incorrect. Creating your encryption algorithm is not recommended since it is hard to ensure that the algorithm can resist all types of attacks.
D. Salting the hash: This option is correct. Salting the hash involves adding a random string of data to the password before hashing it. This makes it more difficult for an attacker to precompute a dictionary of hashes and use it to crack passwords. Thus, option D is the correct answer.
The Answer is: D