views:

219

answers:

3

I am creating a custom CMS and have built a login system and was wandering how vulnerable hashing the passwords this way would be compared to just using the md5 php function like this:

<?php $token = md5($salt . $password . $pepper); ?>

Most people just add a salt but adding pepper just makes sense if your going to add salt :)

Here is how I am doing it

<?php $token = hash_hmac('sha512', $salt . $password . $pepper, $key); ?>

The $key would be a value in the database that is unique to each user. The $salt and the $pepper are randomly generated strings. The $password is the password of course.

Added on 07/24/09

Thanks for all your responses. Does anyone have an examples of how they do a hash script for creating passwords to store in a database?

A: 

Your method is using a stronger hash.

I don't see you opening yourself to any extra vulnerabilities.

Callum
A: 

MD5 is not suitable for any cryptographic purpose, use SHA-1 or preferable SHA-256.

http://www.mscs.dal.ca/~selinger/md5collision/

Yeah... that's probably why he's using SHA-512.
Tim Sylvester
Yeah I got turned on to the SHA-512 because of the length of the encryption
Will Ayers