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 6612741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:08:03+00:00 2026-05-25T20:08:03+00:00

I am salting users’ passwords with a mysql column which has the type timestamp

  • 0

I am salting users’ passwords with a mysql column which has the type timestamp and default is CURRENT TIMESTAMP.

Both of my timezones for mysql and php are identical.

My problem is this,

 $q = $dbc -> prepare("INSERT INTO accounts (password) VALUES (?)");
 $q -> execute(array(hash('sha512', 'somestaticsalt' .  $_POST['password'] . time())));

Now as you can see I have to hash with PHP’s time function and on the mysql side it is a default timestamp.

Somewhere there must be an overlap because where users’ are entering correct information it is still failing to match the hashed password in the database.

I have tried inserting time() into the joined column but it returns at 1970. Also I do not want to save the timestamp as an INT as this isn’t the correct thing to do, so what is your thoughts?

  • 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-25T20:08:04+00:00Added an answer on May 25, 2026 at 8:08 pm

    Your salt really should be random.

    A small improvement on your code (you could do a lot better, like use bcrypt or at least some stretching on sha512):

    $salt = md5(time() . 'some-other-static-salt'); //more random than time() along.
    $q = $dbc -> prepare("INSERT INTO accounts (password, salt) VALUES (?, ?)");
    $q -> execute(array(hash('sha512', 'somestaticsalt' .  $_POST['password'] . $salt), $salt));
    

    Now you’re no longer depending on CURRENT_TIMESTAMP returning the same thing as time(), and you’ve got a better salt.

    EDIT: if you insist on doing it your way, look at what mysql returns for that timestamp column. I bet it looks like “Y-m-d H:i:s” and not like a unix timestamp. Of course, you should have been able to figure that out yourself. Assuming that’s true, wrap it in strtotime and you might have some success.

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

Sidebar

Related Questions

I am seeking advice on how to securely store passwords in MySQL using PHP.
I've been reading up on the benefits of salting and hashing passwords, but one
I've spent the past 2 hours reading up on salting passwords, making sure that
Is there any benefit in salting passwords for a strong, unique (not used for
I've read a ton of information about hashing and salting passwords, do's, don't etc.
I've always been curious... Which is better when salting a password for hashing: prefix,
I have a database which has form authentication tables for an website [let say
I use asp.net forms authentication to handle hashing/salting to and from plaintext passwords to
I'm writing an app which main purpose is to keep list of users purchases.
This is a question about salting phrases that need to be hashed. I was

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.