Это мой PHP-код:
Код: Выделить всё
hash_file("sha256", $filePath)
Код: Выделить всё
const hash = crypto.SHA256(crypto.lib.WordArray.create(buffer));
const hexHash = hash.toString(crypto.enc.Hex);
Отредактировано:
Это изображение, которое я использую для тестирования
При отправке изображения на сервер:
В php: изображение сохраняется в определенной папке после запуска функции изменения размера:
Код: Выделить всё
public static function resize($fromPath,$height,$toPath=null,$quality=100) {
$done = false;
if($toPath==null)$toPath = $fromPath;
$img = new Imagick($fromPath);
self::autorotate($img);
$img->setImageCompression(Imagick::COMPRESSION_JPEG);
$img->setImageCompressionQuality($quality);
if($img->scaleImage(0,$height)){
$img->stripImage();
$done = $img->writeImage($toPath);
}
self::_clean($img);
return $done;
}
и в javascript я использую Sharp, чтобы изменить размер на тот же размер и все такое:
Код: Выделить всё
const input = typeof file !== 'string' && file.buffer ? file.buffer : file;
const { width, height } = await sharp(input).metadata();
const buffer = await sharp(input)
.toFormat('jpeg')
.jpeg({
quality: 75,
chromaSubsampling: "4:2:0",
})
.resize(Math.round((maxHeight * width) / height), maxHeight)
.toBuffer();
влияют ли различия в атрибутах файла на хэш-значение?< /п>
Подробнее здесь: https://stackoverflow.com/questions/790 ... javascript
Мобильная версия