/    Sign up×
Community /Pin to ProfileBookmark

Salted Passwords

I’m dipping my toe in the water of salted passwords by upgrading an older webapp, and would like to present the rough outline of how my system would work in the hope that those with more experience than I might tell me if I’m going in the right direction;

In general terms:

[QUOTE]

[COLOR=”#800000″]***** SET/CHANGE PASSWORD *****

$salt = md5(time());
$salted_password = hash(‘sha256’, $salt . $_POST[‘password’]); // Hash the password

Insert $salt and $salted_password into the database user table

***** LOGIN *****
Pull salt from database
Prepend salt to submitted password, generate SHA256 hash to compare against password from db

Attempt to pull user record from database using username submitted and password hash just generated:
“SELECT * FROM usertable WHERE user = ‘…’ and password = ‘…’ LIMIT 1” (username and password values are escaped)

If row count is less than one, present error message and close page.

Otherwise, set cookies, user is logged in.[/COLOR]

[/QUOTE]

Am I on the right track here? From what I’ve read, a sha256 hash with a unique salt of 32 characters would be pretty robust, but I’d like to have someone else look at this to tell me if there’s some glaring, or even subtle, logical error here.

Your assistance is appreciated.

Rob

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @scaiferw spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...