PHP/Utility Function/sha1
Версия от 10:37, 26 мая 2010; (обсуждение)
Comparing the output of md5 to that of sha1
<?php
echo "Encrypting <b>testing</b> using md5: ".md5("testing");
echo "<br />";
echo "Encrypting <b>testing</b> using sha1: ".sha1("testing");
?>
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>";
?>
string sha1 ( string str [, bool raw_output] )
<?
print sha1("hello") . "\n";
print sha1("Hello") . "\n";
print sha1("hello") . "\n";
print sha1("This is a very, very, very, very, very, very, very long test");
?>