MENU
General Hashing
crc32($s) returns an integer which is the cyclic-redundancy-checksum polynomial of $s. It is 32 bits long. crypt($s1[,$s2]) returns a hashed string of $s1, using the standard Unix DES-based algorithm. $s2 is the salt string to base the hashing on. md5 ($s[,$b=false]) returns the MD5 hash of $s, which is a string storing a 32-character hexadecimal number. If $b is true, the hash is in raw binary format with a length of 16. md5_file($s [,$b=false]) is similar to md5() except that instead of a string, $s is the name of the file to be hashed. sha1($s [,$b=false]) returns the sha1 hash of $s, which is a string storing a 40-character hexadecimal number. If $b is true, the hash is in raw binary format with a length of 20. sha1_file ($s[,b]) is similar to sha1() except that instead of a string, $s is the name of the file to be hashed.RESETRUNFULL
<!DOCTYPE html><html><head></head>
<body><?php
$s = "hello world";
echo crc32($s)."<br />";
echo crypt($s)."<br />"; // different each time
echo crypt($s,"ABC")."<br />";
echo md5($s)."<br />";
echo sha1($s)."<br />";
?></body></html>
RESETRUNFULL
<!DOCTYPE html><html><head></head>
<body><?php
$s = "PHP 5.4.0\n\r";
echo str_rot13($s)."<br />";
echo str_rot13(str_rot13($s))."<br />";
echo bin2hex($s)."<br />";
echo hex2bin(bin2hex($s))."<br />";
echo convert_uuencode($s)."<br />";
echo convert_uudecode(convert_uuencode($s))."<br />";
echo quoted_printable_encode($s)."<br />";
echo quoted_printable_decode( quoted_printable_encode($s))."<br />";
?></body></html>
<?php
print_r(hash_algos());
?>
Array ( [0] => md2 [1] => md4 [2] => md5 [3] => sha1 [4] => sha224 [5] => sha256 [6] => sha384 [7] => sha512 [8] => ripemd128 [9] => ripemd160 [10] => ripemd256 [11] => ripemd320 [12] => whirlpool [13] => tiger128,3 [14] => tiger160,3 [15] => tiger192,3 [16] => tiger128,4 [17] => tiger160,4 [18] => tiger192,4 [19] => snefru [20] => snefru256 [21] => gost [22] => adler32 [23] => crc32 [24] => crc32b [25] => fnv132 [26] => fnv164 [27] => joaat [28] => haval128,3 [29] => haval160,3 [30] => haval192,3 [31] => haval224,3 [32] => haval256,3 [33] => haval128,4 [34] => haval160,4 [35] => haval192,4 [36] => haval224,4 [37] => haval256,4 [38] => haval128,5 [39] => haval160,5 [40] => haval192,5 [41] => haval224,5 [42] => haval256,5 )
RESETRUNFULL
<?php
echo hash('sha1','Please code PHP well.')."<br/>";
file_put_contents('eg.txt', 'Please code PHP well.');
echo hash_file('sha1', 'eg.txt');
?>
RESETRUNFULL
<?php
$c = hash_init('md5');
hash_update($c, 'PHP is really fun.');
hash_update($c, 'Do you agree?');
hash_update_file($c,'eg.txt');
echo hash_final($c);
?>