public function getHash(): string
    {
        $init = $this->pos;
        \fseek($this->fp, 0, SEEK_SET);

        // Create a hash context:
        $h = \sodium_crypto_generichash_init(
            $this->hashKey,
            \SODIUM_CRYPTO_GENERICHASH_BYTES_MAX
        );
        for ($i = 0; $i < $this->stat['size']; $i += self::CHUNK) {
            if (($i + self::CHUNK) > $this->stat['size']) {
                $c = \fread($this->fp, ((int) $this->stat['size'] - $i));
            } else {
                $c = \fread($this->fp, self::CHUNK);
            }
            if (!\is_string($c)) {
                // @codeCoverageIgnoreStart
                throw new FileError('Could not read file');
                // @codeCoverageIgnoreEnd
            }
            \sodium_crypto_generichash_update($h, $c);
        }
        // Reset the file pointer's internal cursor to where it was:
        \fseek($this->fp, $init, SEEK_SET);
        return \sodium_crypto_generichash_final($h);
    }
public function getHash(): string
    {
        $init = $this->pos;
        \fseek($this->fp, 0, SEEK_SET);

        // Create a hash context:
        $h = \sodium_crypto_generichash_init(
            $this->hashKey,
            \SODIUM_CRYPTO_GENERICHASH_BYTES_MAX
        );
        for ($i = 0; $i < $this->stat['size']; $i += self::CHUNK) {
            if (($i + self::CHUNK) > $this->stat['size']) {
                $c = \fread($this->fp, ((int) $this->stat['size'] - $i));
            } else {
                $c = \fread($this->fp, self::CHUNK);
            }
            if (!\is_string($c)) {
                // @codeCoverageIgnoreStart
                throw new FileError('Could not read file');
                // @codeCoverageIgnoreEnd
            }
            \sodium_crypto_generichash_update($h, $c);
        }
        // Reset the file pointer's internal cursor to where it was:
        \fseek($this->fp, $init, SEEK_SET);
        return \sodium_crypto_generichash_final($h);
    }
public function getHash ( ) : string { $ init = $ this -> pos ; \ fseek ( $ this -> fp , 0 , SEEK_SET ) ; // Create a hash context: $ h = \ sodium_crypto_generichash_init ( $ this -> hashKey , \ SODIUM_CRYPTO_GENERICHASH_BYTES_MAX ) ; for ( $ i = 0 ; $ i < $ this -> stat [ 'size' ] ; $ i += self :: CHUNK ) { if ( ( $ i + self :: CHUNK ) > $ this -> stat [ 'size' ] ) { $ c = \ fread ( $ this -> fp , ( ( int ) $ this -> stat [ 'size' ] - $ i ) ) ; } else { $ c = \ fread ( $ this -> fp , self :: CHUNK ) ; } if ( ! \ is_string ( $ c ) ) { // @codeCoverageIgnoreStart throw new FileError ( 'Could not read file' ) ; // @codeCoverageIgnoreEnd } \ sodium_crypto_generichash_update ( $ h , $ c ) ; } // Reset the file pointer's internal cursor to where it was: \ fseek ( $ this -> fp , $ init , SEEK_SET ) ; return \ sodium_crypto_generichash_final ( $ h ) ; }
Calculate a BLAKE2b hash of a file

@return string
Calculate a BLAKE2b hash of a file