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

  • Home
  • SEARCH
  • 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 4250868
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:35:06+00:00 2026-05-21T04:35:06+00:00

Reading this excellent answer about password hashing and wondering how to implement it: The

  • 0

Reading this excellent answer about password hashing and wondering how to implement it:

The Wicked Flea wrote:

Generate a nonce for each user; this alone defeats the rainbow table. This is a random number that, depending on the range, expands how many resulting hashes there are.

So beside users’ password store a unique token in my database?

The example code in the original post:

function hash_password($password, $nonce) {
  global $site_key;
  return hash_hmac('sha512', $password . $nonce, $site_key);
}

How can i verify a password with this code? Let me explain:

When user submits his password i need to generate it’s hash to check for an existing database row where email address and hashed password match. How can i select this row when i know nothing about users’ $nonce? Am i missing something? Maybe i need to select user by only his e-mail address then verify the password hash later?

Btw, do you recommend this hashing method?

  • 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-21T04:35:07+00:00Added an answer on May 21, 2026 at 4:35 am

    I think you have nailed the idea. The same concept is applied in general UNIX-style salted passwords – store salt in clear text with password and retrieve it by username, then use the salt and provided password to produce new hash to be compared to the stored value.

    It is up to you to consider wether you trust your DB server (and the connection to it) to use a hashing algorithm that is supported by the DB and let the DB do the math:

    SELECT * FROM users WHERE email = 'email' AND password = SHA1(CONCAT('cleartextpass',nonce));
    

    Or you could do the math in the code after retrieving all the matching emails.

    EDIT: The ThiefMaster comment on differentiating between missing user and invalid password is classical security flaw, which allows attackers to acquire a list of valid usernames and concentrate on breaking their passwords instead of fishing in the darkness. I would strongly recommend against it.

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

Sidebar

Related Questions

After reading this discussion and this discussion about using CrashRpt to generate a crash
Reading this post has left me wondering; are nightly builds ever better for a
Reading this blog post about HttpOnly cookies made me start thinking, is it possible
After reading this answer: best way to pick a random subset from a collection?
I was reading this question about how to parse URLs out of web pages
I was reading this article about Double-Checked locking and out of the main topic
I've been reading this article about closures in which they say: all the plumbing
I was reading this excellent article which gives an introduction to Asynchronous programming here
I was reading this article about volatile fields in C#. using System; using System.Threading;
Reading this question I found this as (note the quotation marks) code to solve

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.