Author Topic: Check MD5 of file - or Create it  (Read 3195 times)

0 Members and 1 Guest are viewing this topic.

Ketxu

  • Newt
  • Posts: 109
Check MD5 of file - or Create it
« on: January 11, 2012, 05:09:40 AM »
Hi all
As the title, i'm finding lisp code to check MD5 of file (Create it).
Sometime, i want to check my file (vlx, dcl...) has not been modify by user.
I will write MD5 of file to registry and compare with what i receive all times function call. If it not same, disable it
Has anyone has solution of this probem, please help me. Thank all ^^

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Check MD5 of file - or Create it
« Reply #1 on: January 11, 2012, 06:13:23 AM »
Not directly, you could use something like the ActiveX-xmd5 DLL: http://xstandard.com/en/documentation/xmd5/

But that's less than ideal as you'd need to install the DLL together with your code. In which case you could've written your own DLL in DotNet.

Edit: If you want to you could write the algorithm in lisp itself. http://en.wikipedia.org/wiki/MD5#Pseudocode
« Last Edit: January 11, 2012, 06:19:59 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Check MD5 of file - or Create it
« Reply #2 on: January 16, 2012, 04:53:20 AM »
Alternatively you could use DosLib's dos_filecrc function. Though you'd still need DosLib in the client's Acad installation, either as a separate install, or through your own installation.

The CRC32 would give you much the same as MD5, CRC64 would actually give more "accurate" calculations. Unfortunately AutoLisp uses signed 32bit integers so it's difficult to near impossible to calculate such in pure AutoLisp.

A further alternative would be to use randomized numbers with each character in the file as the consecutive seed values. Then use the random as index in a translation table. Combining the values into one through some form of math. I.e. you create a hash code for the file as a single large string, just note that most hash-code generators cannot guarantee that clashes won't occur. Even MD5/SHA/CRC cannot guarantee non-clashing numbers, but they tend to be extremely unlikely. Depending on the hash-code generation (especially the math used to combine the consecutive numbers) the likelihood of clashes can vary greatly.

What you're after is a hash which would calculate to a totally different number if only a single character in 1000's is different.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

CADmium

  • Newt
  • Posts: 33
Re: Check MD5 of file - or Create it
« Reply #3 on: February 21, 2012, 03:28:00 AM »
Some years ago i wrote a function for creating of Md5Hashs . Here is the Code
"Bei 99% aller Probleme ist die umfassende Beschreibung des Problems bereits mehr als die Hälfte der Lösung desselben."

diogenes

  • Mosquito
  • Posts: 5
Re: Check MD5 of file - or Create it
« Reply #4 on: February 14, 2023, 09:10:29 AM »
I am sorry to inform you that there is a problem, as it is easy to reverse the process:
https://md5.gromweb.com/

kozmos

  • Newt
  • Posts: 114
Re: Check MD5 of file - or Create it
« Reply #5 on: February 19, 2023, 10:44:43 PM »
Hi all
As the title, i'm finding lisp code to check MD5 of file (Create it).
Sometime, i want to check my file (vlx, dcl...) has not been modify by user.
I will write MD5 of file to registry and compare with what i receive all times function call. If it not same, disable it
Has anyone has solution of this probem, please help me. Thank all ^^

You can use "FileHash" in "WindowsInstaller.Installer" by ActiveX to generate your own version of MD5 of a file.
KozMos Inc.

mariolino0099

  • Newt
  • Posts: 25
Re: Check MD5 of file - or Create it
« Reply #6 on: February 21, 2023, 12:55:49 PM »