初始化代码
This commit is contained in:
36
vendor/league/flysystem/src/Util/StreamHasher.php
vendored
Normal file
36
vendor/league/flysystem/src/Util/StreamHasher.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user