organizrnginxsonarrradarrplexdashboardcouchpotatonzbgetbookmarkapplication-dashboardmuximuxlandingpagestartpagelandinghtpcserverhomepagesabnzbdheimdallemby
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
593 B
37 lines
593 B
7 years ago
|
<?php
|
||
|
|
||
|
namespace League\Flysystem\Util;
|
||
|
|
||
|
class StreamHasher
|
||
|
{
|
||
|
/**
|
||
|
* @var string
|
||
|
*/
|
||
|
private $algo;
|
||
|
|
||
|
/**
|
||
|
* StreamHasher constructor.
|
||
|
*
|
||
|
* @param string $algo
|
||
|
*/
|
||
|
public function __construct($algo)
|
||
|
{
|
||
|
$this->algo = $algo;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param resource $resource
|
||
|
*
|
||
|
* @return string
|
||
|
*/
|
||
|
public function hash($resource)
|
||
|
{
|
||
|
rewind($resource);
|
||
|
$context = hash_init($this->algo);
|
||
|
hash_update_stream($context, $resource);
|
||
|
fclose($resource);
|
||
|
|
||
|
return hash_final($context);
|
||
|
}
|
||
|
}
|