getid3_lib::hash_data

Advertisement

Summery Summery

Returns checksum for a file from starting position to absolute end position.

Syntax Syntax

getid3_lib::hash_data( string $file, int $offset, int $end, string $algorithm )

Parameters Parameters

$file

(string) (Required)

$offset

(int) (Required)

$end

(int) (Required)

$algorithm

(string) (Required)

Return Return

(string|false)

Source Source

File: wp-includes/ID3/getid3.lib.php

		}
		if (!in_array($algorithm, array('md5', 'sha1'))) {
			throw new getid3_exception('Invalid algorithm ('.$algorithm.') in self::hash_data()');
		}

		$size = $end - $offset;

		$fp = fopen($file, 'rb');
		fseek($fp, $offset);
		$ctx = hash_init($algorithm);
		while ($size > 0) {
			$buffer = fread($fp, min($size, getID3::FREAD_BUFFER_SIZE));
			hash_update($ctx, $buffer);
			$size -= getID3::FREAD_BUFFER_SIZE;
		}
		$hash = hash_final($ctx);
		fclose($fp);

		return $hash;
	}

	/**
	 * @param string $filename_source

Advertisement

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.