Hashing DWG files - empty models don't receive the same hash code

Hashing DWG files - empty models don't receive the same hash code

Anonymous
Not applicable
2,702 Views
7 Replies
Message 1 of 8

Hashing DWG files - empty models don't receive the same hash code

Anonymous
Not applicable

I want to use a hash function (SHA1) to determine whether two DWG models from AutoCAD 2018 are identical or not. To test if this works, I created two empty dwg files and used the SHA1 function in c# (System.Security.Cryptography.sha1) to calculate the hash code.

 

I was expecting resulting codes to be identical, since I only started two new empty models and then saved them directly. The only data which should differ is the name and date & time of creation (all meta data, which shouldn't play a role for the algorithm). Yet, the result was two different hash codes.

 

So I looked into the byte array of the two files. The only thing I could get out of it (a lot of lines which I could not interpret in any way), was that some of the meta data as date and time of creation is written in the byte array. Therefore the two files are actually not identical, eventhough the models are. So there will always be a different hash code for all hashed DWG models.

 

Does anyone know of this problem or a work-around for my issue?

 

 

Snippet of the byte array in which the saving time and date is captured:

 

A p p I n f o D a t a L i s t �H��

M��ρ��P� 2 2 . 0 . 4 9 . 0 . 0 ���%�דI����(o��r A u t o d e s k D W G . T h i s f i l e i s a T r u s t e d D W G l a s t s a v e d b y a n A u t o d e s k a p p l i c a t i o n o r A u t o d e s k l i c e n s e d a p p l i c a t i o n . �����Oh�� +'��J< p r o p _ s e t f m t _ i d = " { f 2 9 f 8 5 e 0 - 4 f f 9 - 1 0 6 8 - a b 9 1 - 0 8 0 0 2 b 2 7 b 3 d 9 } " > < p r o p i d = " 8 " > < s t r i n g > M a x < / s t r i n g > < / p r o p > < p r o p i d = " 1 0 " > < d a t e t i m e > 2 0 2 0 - 0 7 - 1 4 T 0 9 : 5 1 : 3 3 < / d a t e t i m e > < / p r o p > < p r o p i d = " 2 5 8 " > < s t r i n g > A u t o C A D 2 0 1 8 < / s t r i n g > < / p r o p > < p r o p i d = " 2 5 9 " > < s t r i n g > O . 4 9 . 0 . 0 < / s t r i n g > < / p r o p > < p r o p i d = " 1 2 " > < d a t e t i m e > 2 0 2 0 - 0 7 - 1 4 T 0 9 : 5 1 : 2 9 < / d a t e t i m e > < / p r o p > < / p r o p _ s e t > ���Q�βD����;��D� " < P r o d u c t I n f o r m a t i o n n a m e = \ " A u t o C A D \ " b u i l d _ v e r s i o n = \ " O . 4 9 . 0 . 0 ( x 6 4 ) \ " r e g i s t r y _ v e r s i o n = \ " 2 2 . 0 \ " i n s t a l l _ i d _ s t r i n g = \ " A C A D - 1 0 0 1 : 4 0 9 \ " r e g i s t r y _ l o c a l e I D = \ " 1 0 3 3 \ " > "

0 Likes
2,703 Views
7 Replies
Replies (7)
Message 2 of 8

JTBWorld
Advisor
Advisor

Hashing can't be used. It's much more complex than that to figure out if they are equal. 


Jimmy Bergmark
JTB World - Software development and consulting for CAD and license usage reports
https://jtbworld.com

Message 3 of 8

RobDraw
Mentor
Mentor

There are many ways to compare drawings. What is the purpose of this comparison?


Rob

Drafting is a breeze and Revit doesn't always work the way you think it should.
0 Likes
Message 4 of 8

tim_crouse
Collaborator
Collaborator

 

Although the objects in the drawings may be identical there are other unseen aspects that are not identical.

 

The first one that comes to mind is the metadata associated, one such piece is the amount of time spent in the drawing which will be different between the two drawings.

 

Although the HASH will be a tough way to determine duplicity as a basic test to test your concept would be to perform the operation on a copy of the drawing.  This could have some benefits, albeit not what you originally intended.

 

Best Regards

-Tim C.

 

 

Message 5 of 8

Anonymous
Not applicable

I wanted to create a table of all past versions/variants of some projects. To be able to assign the versions in the table to the 3D models afterwards, I thought of using a hash code.

0 Likes
Message 6 of 8

Anonymous
Not applicable

@tim_crouse

I managed to compute a human-readable byte array by using the DXF file format. Just like you said, the amount of time spend in the drawing is also saved into the byte array. In addition, the $FINGERPRINTGUID also differs:

 

$TDCREATE
40
2459045.493807870
9
$TDUCREATE
40
2459045.410474537
9
$TDUPDATE
40
2459050.246168982
9
$TDUUPDATE
40
2459050.162835648
9
$TDINDWG
40
0.0003935185
9
$TDUSRTIMER
40
0.0003935185
9
$USRTIMER
70
1
9

 

I believe it wouldn't suffice to just delete/ignore these lines in the byte array, because a different view/orientation of the same model would lead to changes in the byte array? With that, it will be quite hard to use hash codes to determine identical looking models.

 

When just copying and pasting a basic 3D model, the hash will be identical.

0 Likes
Message 7 of 8

RobDraw
Mentor
Mentor

@Anonymous wrote:

I wanted to create a table of all past versions/variants of some projects. To be able to assign the versions in the table to the 3D models afterwards, 


 

That sounds different from your original question about checking to see if they are duplicates.


Rob

Drafting is a breeze and Revit doesn't always work the way you think it should.
0 Likes
Message 8 of 8

dgorsman
Consultant
Consultant

Version control is best handled with a proper EDMS, such as Vault, Projectwise, or Adept.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.