src/Alo.php
public static function getUniqid($hash = 'sha256', $prefix = '', $entropy = 10000, $rawOutput = false) {
            $str = mt_rand(~PHP_INT_MAX, PHP_INT_MAX) . json_encode([$_COOKIE,
                                                                     $_REQUEST,
                                                                     $_FILES,
                                                                     $_ENV,
                                                                     $_GET,
                                                                     $_POST,
                                                                     $_SERVER]) . uniqid($prefix, true) .
                   self::asciiRand($entropy, self::ASCII_ALL);

            if (function_exists('\openssl_random_pseudo_bytes')) {
                $algoStrong = null;
                $str .= \openssl_random_pseudo_bytes($entropy, $algoStrong);

                if ($algoStrong !== true) {
                    trigger_error('Please update your openssl & PHP libraries. openssl_random_pseudo_bytes was unable' .
                                  ' to locate a cryptographically strong algorithm.',
                                  E_USER_WARNING);
                }
            } else {
                trigger_error('The openssl extension is not enabled, therefore the unique ID is not ' .
                              'cryptographically secure.',
                              E_USER_WARNING);
            }

            return hash($hash, $str, $rawOutput);
        }
public static function getUniqid($hash = 'sha256', $prefix = '', $entropy = 10000, $rawOutput = false) {
            $str = mt_rand(~PHP_INT_MAX, PHP_INT_MAX) . json_encode([$_COOKIE,
                                                                     $_REQUEST,
                                                                     $_FILES,
                                                                     $_ENV,
                                                                     $_GET,
                                                                     $_POST,
                                                                     $_SERVER]) . uniqid($prefix, true) .
                   self::asciiRand($entropy, self::ASCII_ALL);

            if (function_exists('\openssl_random_pseudo_bytes')) {
                $algoStrong = null;
                $str .= \openssl_random_pseudo_bytes($entropy, $algoStrong);

                if ($algoStrong !== true) {
                    trigger_error('Please update your openssl & PHP libraries. openssl_random_pseudo_bytes was unable' .
                                  ' to locate a cryptographically strong algorithm.',
                                  E_USER_WARNING);
                }
            } else {
                trigger_error('The openssl extension is not enabled, therefore the unique ID is not ' .
                              'cryptographically secure.',
                              E_USER_WARNING);
            }

            return hash($hash, $str, $rawOutput);
        }
public static function getUniqid ( $ hash = 'sha256' , $ prefix = '' , $ entropy = 10000 , $ rawOutput = false ) { $ str = mt_rand ( ~ PHP_INT_MAX , PHP_INT_MAX ) . json_encode ( [ $ _COOKIE , $ _REQUEST , $ _FILES , $ _ENV , $ _GET , $ _POST , $ _SERVER ] ) . uniqid ( $ prefix , true ) . self :: asciiRand ( $ entropy , self :: ASCII_ALL ) ; if ( function_exists ( '\openssl_random_pseudo_bytes' ) ) { $ algoStrong = null ; $ str .= \ openssl_random_pseudo_bytes ( $ entropy , $ algoStrong ) ; if ( $ algoStrong !== true ) { trigger_error ( 'Please update your openssl & PHP libraries. openssl_random_pseudo_bytes was unable' . ' to locate a cryptographically strong algorithm.' , E_USER_WARNING ) ; } } else { trigger_error ( 'The openssl extension is not enabled, therefore the unique ID is not ' . 'cryptographically secure.' , E_USER_WARNING ) ; } return hash ( $ hash , $ str , $ rawOutput ) ; }
Generates a unique identifier

@author Art <a.molcanovas@gmail.com>

@param string $hash      Hash algorithm
@param string $prefix    Prefix for the identifier
@param int    $entropy   Number of pseudo bytes used in entropy
@param bool   $rawOutput When set to true, outputs raw binary data. false outputs lowercase hexits.

@return string
@see    https://secure.php.net/manual/en/function.hash.php
@see    https://secure.php.net/manual/en/function.openssl-random-pseudo-bytes.php
@since  1.3.3 Default $entropy value set to 10000, a warning is triggered if openssl_random_pseudo_bytes is
unable to locate a cryptographically strong algorithm.<br/>
1.3
@codeCoverageIgnore
Generates a unique identifier