0
$\begingroup$

I am trying to compare hashes of blend files, but I'm running into a few problems. Every time I open Blender and write the default cube mesh to another file and then hash that file, the hash is different. I run the following code from the python console:

from hashlib import sha1
bpy.data.libraries.write('//Lib.blend', {C.object.data})
sha1(open(bpy.path.abspath('//Lib.blend'), 'rb').read()).hexdigest() // resulting hash, different every time

This also happens when I, for example, switch to and from edit mode without altering the mesh. Every time, another hash.

I've been searching the API and the source code to see whether a timestamp is added to the blend file, but have been unable to find anything. Interestingly, when I execute the above code twice without re-opening or editing any object in the scene, the hashes do remain the same.

What causes the hashes to keep changing, even though the data is the same?

$\endgroup$
0
$\begingroup$

I was interested in this so did a little research.

A blender save works by directly copying the scene data from memory to disk. This makes the save fast since there is no need for a 'conversion' stage.

This means that any change to how that data is in memory will result in the same change when in a blend file. This could be trivial changes like the order of variables in a list.

read this for more details: http://archive.blender.org/development/architecture/blender-file-format/

"Blend-files can be different when stored on different hardware platforms or Blender releases. There is no effort taken to make blend-files binary the same."

Basically it means that hashing the file cannot be used to check for content changes.

R

$\endgroup$
  • $\begingroup$ Well, that's unfortunate. I'm reading the article you linked, but one thing is not entirely clear to me: Which data/variables can be different? The old memory address in the file block header, the order of file blocks, and pointers inside file blocks. But what about any other data? $\endgroup$ – User Jan 2 '17 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.