1. Go to this page and download the library: Download loophp/path-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/ */
loophp / path-hasher example snippets
use Loophp\PathHasher\NAR;
$path = '/path/to/your/file_or_directory';
$hash = (new NAR())->hash($path);
echo $hash; // Outputs the SRI hash (e.g., sha256-<base64>)
use Loophp\PathHasher\NAR;
$nar = new NAR();
$handle = fopen('vendor.nar', 'w');
foreach ($nar->stream('./vendor') as $chunk) {
fwrite($handle, $chunk);
}
fclose($handle);
use Loophp\PathHasher\SWHID;
$path = '/path/to/your/file_or_directory';
// Compute the SWHID for a file, directory, or symlink
$swhid = (new SWHID())->hash($path);
echo $swhid; // Outputs e.g. swh:1:cnt:<sha1> or swh:1:dir:<sha1>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.