PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

hash_file> <hash
Last updated: Mon, 26 Nov 2007

view this page in

hash_algos

(PHP 5 >= 5.1.2, PECL hash:1.1-1.5)

hash_algos — Return a list of registered hashing algorithms

说明

array hash_algos ( void )

返回值

Returns a numerically indexed array containing the list of supported hashing algorithms.

范例

Example#1 hash_algos() example

As of PHP 5.1.2, hash_algos() will return the following list of algorithm names.

<?php
print_r
(hash_algos());
?>

上例将输出:

Array
(
    [0] => md4
    [1] => md5
    [2] => sha1
    [3] => sha256
    [4] => sha384
    [5] => sha512
    [6] => ripemd128
    [7] => ripemd160
    [8] => whirlpool
    [9] => tiger128,3
    [10] => tiger160,3
    [11] => tiger192,3
    [12] => tiger128,4
    [13] => tiger160,4
    [14] => tiger192,4
    [15] => snefru
    [16] => gost
    [17] => adler32
    [18] => crc32
    [19] => crc32b
    [20] => haval128,3
    [21] => haval160,3
    [22] => haval192,3
    [23] => haval224,3
    [24] => haval256,3
    [25] => haval128,4
    [26] => haval160,4
    [27] => haval192,4
    [28] => haval224,4
    [29] => haval256,4
    [30] => haval128,5
    [31] => haval160,5
    [32] => haval192,5
    [33] => haval224,5
    [34] => haval256,5
)



add a note add a note User Contributed Notes
hash_algos
elinor dot hurst at gmail dot REMOVEME dot com
01-Jul-2008 04:52
static 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;
    }

hash_file> <hash
Last updated: Mon, 26 Nov 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites