Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7651027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:24:11+00:00 2026-05-31T11:24:11+00:00

While reading the Hashing topic of C# in a nutshell book,i came across the

  • 0

While reading the Hashing topic of C# in a nutshell book,i came across the following quotes!

You can provide additional protection against dictionary attack by
“stretching” your password hashes—repeatedly rehashing to obtain more
computationally intensive byte sequences. If you rehash 100 times, a
dictionary attack that might otherwise take 1 month would take 8
years.

So I implemented it this way!

byte[] data = Encoding.UTF8.GetBytes("Password is 12345679");
byte[] hash = SHA512.Create().ComputeHash(data);
int temp=0;
while (temp < 100)
{
    hash = SHA512.Create().ComputeHash(hash);
    temp++;
}

Is the above code right? Will a dictionary attack really take 8 years or so to decipher?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:24:13+00:00Added an answer on May 31, 2026 at 11:24 am

    In the absence of shortcuts (as noted by @Random832), one should expect it to take 100x as long to brute-force test something that has been hashed 100 times as one. If the attacker is looking at every sequence of characters looking for a hash that matches, then anything that makes that hash take longer is going to slow him down (or equivalently, use more computing power).

    Continuing to steal from Random832, this is a “poor-man’s stretching.” It is adequate and useful, but if you have the PBKDF2 function available, that is preferred, since PBKDF2 is well-analyzed by cryptographers. In the strictest sense, your code above is a “Password Based Key Derivation Function” (PBKDF), but PBKDF2 is a specific one. EDIT: I’m not a C# developer by trade, but it does look like .NET includes a PBKDF2 function Rfc2898DeriveBytes.

    Note the key phrase in the above text, though: “that might otherwise take 1 month.” The writer is assuming it would take a month to do the first, and 8 years is approximately 100 months. If it would have taken 1 minute to perform a dictionary attack on the first, you should expect it to take about 1.5 hours to do so on the second. There is no magic “8 years” here. It’s just 100x the first number, whatever that first number happens to be.

    EDIT: One more thing to note about stretching. You should always salt before you stretch. Salting means you add a random series of bytes to the start of the password. You then encode that salt along with the hash result (the salt is not a secret). So rather than hashing “Password is 12345679”, you would hash “deadbeefPassword is 12345679” and you would then send “deadbeef” in the clear along with the final result. The reason you do this is because people choose the same passwords all the time. So if the attacker works out the result of hashing “Passw0rd!” then he could just check that result against your hash. Much cheaper. Similarly, if he had both Alice and Bob’s hashes, he could tell if they were the same or different. But with a random salt, you can’t do that, since it is almost certain that Alice and Bob will have their data hashed with different salts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While reading Joe Albahari's excellent book Threading in C# I came across the following
While reading Jack Shirazi's 'Java performance tuning', I came across the following statement: Instance
While reading a book, i came across this statement: The methods of an object
While reading SQL Server documentation I came across the following statement: EXEC sp_addlinkedserver @server=N'S1_instance1',
While reading Python scripting for computational science I came across the following text in
While reading Bruce Eckel i came across the following example: #include <cstdio> #include <cstdlib>
While reading some articles about writing web servers using Twisted , I came across
While reading some question on a site I came across below question where a
While reading Java Security I came across the below sentences but could not get
While reading this question , I came across @Johannes 's answer. template<typename> struct void_

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.