note 107337 deleted from function.sha1 by danbrown

From: Date: Thu, 10 May 2012 21:25:47 +0000
Subject: note 107337 deleted from function.sha1 by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-187886@lists.php.net to get a copy of this message
Note Submitter: matt at zigg dot com ---- The hashSSHA function provided in the previous comment has poor salt generation. It only generates four bytes of salt (OpenLDAP generates eight) and uses rand(), which on some platforms can only end up generating 15 bytes of randomness--not to mention it's likely not of cryptographic quality. Use this instead: $salt = mcrypt_create_iv(8, MCRYPT_DEV_URANDOM); $hash = "{SSHA}" . base64_encode(sha1($password . $salt, true) . $salt); If mcrypt is not available, you could instead read eight bytes from /dev/urandom or similar.

« previous php.notes (#187886) next »