public static function checksum(
        $filePath,
        Key $key = null,
        $encoding = Halite::ENCODE_BASE64URLSAFE
    ): string {
        if ($filePath instanceof ReadOnlyFile) {
            $pos = $filePath->getPos();
            $filePath->reset(0);
            $checksum = self::checksumData(
                $filePath,
                $key,
                $encoding
            );
            $filePath->reset($pos);
            return $checksum;
        }

        if (\is_resource($filePath) || \is_string($filePath)) {
            $readOnly = new ReadOnlyFile($filePath);
            try {
                $checksum = self::checksumData(
                    $readOnly,
                    $key,
                    $encoding
                );
                return $checksum;
            } finally {
                if (isset($readOnly)) {
                    $readOnly->close();
                }
            }
        }
        throw new InvalidType(
            'Argument 1: Expected a filename or resource'
        );
    }
public static function checksum(
        $filePath,
        Key $key = null,
        $encoding = Halite::ENCODE_BASE64URLSAFE
    ): string {
        if ($filePath instanceof ReadOnlyFile) {
            $pos = $filePath->getPos();
            $filePath->reset(0);
            $checksum = self::checksumData(
                $filePath,
                $key,
                $encoding
            );
            $filePath->reset($pos);
            return $checksum;
        }

        if (\is_resource($filePath) || \is_string($filePath)) {
            $readOnly = new ReadOnlyFile($filePath);
            try {
                $checksum = self::checksumData(
                    $readOnly,
                    $key,
                    $encoding
                );
                return $checksum;
            } finally {
                if (isset($readOnly)) {
                    $readOnly->close();
                }
            }
        }
        throw new InvalidType(
            'Argument 1: Expected a filename or resource'
        );
    }
public static function checksum ( $ filePath , Key $ key = null , $ encoding = Halite :: ENCODE_BASE64URLSAFE ) : string { if ( $ filePath instanceof ReadOnlyFile ) { $ pos = $ filePath -> getPos ( ) ; $ filePath -> reset ( 0 ) ; $ checksum = self :: checksumData ( $ filePath , $ key , $ encoding ) ; $ filePath -> reset ( $ pos ) ; return $ checksum ; } if ( \ is_resource ( $ filePath ) || \ is_string ( $ filePath ) ) { $ readOnly = new ReadOnlyFile ( $ filePath ) ; try { $ checksum = self :: checksumData ( $ readOnly , $ key , $ encoding ) ; return $ checksum ; } finally { if ( isset ( $ readOnly ) ) { $ readOnly -> close ( ) ; } } } throw new InvalidType ( 'Argument 1: Expected a filename or resource' ) ; }
Calculate the BLAKE2b-512 checksum of a file. This method doesn't load
the entire file into memory. You may optionally supply a key to use in
the BLAKE2b hash.

@param string|resource|ReadOnlyFile $filePath
@param Key $key (optional; expects SignaturePublicKey or
AuthenticationKey)
@param mixed $encoding Which encoding scheme to use for the checksum?
@return string         The checksum

@throws CannotPerformOperation
@throws FileAccessDenied
@throws FileError
@throws InvalidKey
@throws InvalidMessage
@throws InvalidType
@throws \TypeError
Calculate the BLAKE2b - 512 checksum of a file . This method doesn t load the entire file into memory . You may optionally supply a key to use in the BLAKE2b hash .