note 89748 deleted from function.sha1 by danbrown
| From: | danbrown@php.net | Date: | Sat, 21 Mar 2009 14:02:31 +0000 |
| Subject: | note 89748 deleted from function.sha1 by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-152260@lists.php.net to get a copy of this message | ||
Note Submitter: grosbedo at gmail dot com
----
@mVamer :
Your function is quite good and simplified, but you miss the verification procedure, to add it, just
modify this :
<?php
function obscure($password, $algorythm = "sha1")
{
// Get some random salt.
$salt = hash($algorythm, uniqid(rand(), true));
...
?>
to
<?php
function obscure($password, $salt = NULL, $algorythm = "sha1")
{
// Get some random salt, or verify a salt.
if ($salt == NULL) {
$salt = hash($algorythm, uniqid(rand(), true));
}
...
?>
Then you can verify the same way as ranko84's function.
@ranko84 : Here is a more commented version of your code, that I've done as much as I could :
http://snippets.dzone.com/posts/show/7076