Generating a Unique Identifier : sha1 « Utility Function « PHP






Generating a Unique Identifier

 
<?php
function create_unique() {

    $data = $_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR'] . time() . rand();

    return sha1($data);
}

$newhash = create_unique();
echo "<pre>{$newhash}</pre>";
?>
  
  








Related examples in the same category

1.Comparing the output of md5 to that of sha1
2.string sha1 ( string str [, bool raw_output] )