getid3_lib::hash_data() public WP 1.0
Returns checksum for a file from starting position to absolute end position.
{} Это метод класса: getid3_lib{}
Хуков нет.
Возвращает
Строку/false.
Использование
$result = getid3_lib::hash_data( $file, $offset, $end, $algorithm );
- $file(строка) (обязательный)
- $offset(число) (обязательный)
- $end(число) (обязательный)
- $algorithm(строка) (обязательный)
Код getid3_lib::hash_data() getid3 lib::hash data WP 5.6
public static function hash_data($file, $offset, $end, $algorithm) {
if (!self::intValueSupported($end)) {
return false;
}
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;
}