Return to Snippet

Revision: 45357
at April 28, 2011 20:18 by soup


Initial Code
function crypt_pass($pass, $salt=NULL)
    {
        $salt_len=7;
        $algo='sha256';

        if (!$salt||strlen($salt)<$salt_len)
        {
            $salt=uniqid(rand(), TRUE);     // get unique string (length==23)
        }
        $salt=substr($salt, 0, $salt_len);

        if (function_exists('hash') && in_array($algo, hash_algos()))
        {
            $hashed=hash($algo, $salt.$pass);
        }
        else
        {
            $hashed=sha1($salt.$pass);
        }
        return $salt.$hashed;
    }

Initial URL

                                

Initial Description

                                

Initial Title
php password hash function

Initial Tags
php

Initial Language
PHP