How to calculate the sha1 hash of a file in PHP

2 Answers

0 votes
$s = sha1_file("d:\\data.txt"); 

echo $s;


/*
run:
    
8347638d14888ab9c182eacd136dac1f7fd4e158
       
*/

 



answered Jul 17, 2016 by avibootz
0 votes
foreach(glob('*.php') as $file)
{
    if(is_dir($file))
    {
        continue;
    }

    echo $file . ' (SHA1: ' . sha1_file($file) . ')' . "<br />";
}


/*
run:
    
connect.php (SHA1: 73dbf5145799c21586c6d807ca089937b165ad84)
define.php (SHA1: a26d6fcf0b777cb216d54811af7a8ef470e24872)
email.php (SHA1: f56c03790fe339482d56ed74782310e55eb75f5f)
...
       
*/

 



answered Jul 17, 2016 by avibootz

Related questions

2 answers 213 views
1 answer 182 views
1 answer 174 views
2 answers 220 views
1 answer 30 views
...