PHP code example of componenta / file-hasher

1. Go to this page and download the library: Download componenta/file-hasher library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

componenta / file-hasher example snippets


use Componenta\Stdlib\FileHasher;

$hasher = new FileHasher('sha256');

$hash = $hasher->hashFile(__DIR__ . '/document.pdf');
$sha1 = $hasher->withAlgorithm('sha1');

$hasher->algorithm; // sha256

interface FileHasherInterface
{
    public function hashFile(string $filename): string;
}