(PHP) SHA1 vs md5 vs SHA256: which to use for a PHP login?

Posted by hatorade on Stack Overflow See other posts from Stack Overflow or by hatorade
Published on 2010-02-10T07:41:06Z Indexed on 2010/05/08 23:38 UTC
Read the original article Hit count: 1055

Filed under:
|
|
|
|

I'm making a php login, and I'm trying to decide whether to use SHA1 or Md5, or SHA256 which I read about in another stackoverflow article. Are any of them more secure than others? For SHA1/256, do I still use a salt?

Also, is this a secure way to store the password as a hash in mysql?

function createSalt()
{
    $string = md5(uniqid(rand(), true));
    return substr($string, 0, 3);
}

$salt = createSalt();

$hash = sha1($salt . $hash);

© Stack Overflow or respective owner

Related posts about php

Related posts about login