我需要对照Dropbox上的副本来验证本地文件副本的内容。我通过对API v2的get_metadata
方法的请求来获取该信息。
答案 0 :(得分:0)
function dropbox_content_hash($file) {
$fh = fopen($file, 'r');
if (!$fh) {
# warning already issued
return;
}
$hashes = '';
$zero_byte_exception_check = true;
do {
$chunk = fread($fh, 4194304);
if ($zero_byte_exception_check) {
if ($chunk === '') {
return 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';
}
$zero_byte_exception_check = false;
}
$hashes .= hash('sha256', $chunk, true);
} while (!feof($fh));
fclose($fh);
return hash('sha256', $hashes);
}