October 29, 2025, 09:25:00 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


getting MD5 or sha-1 hash code

Started by chris, September 03, 2008, 08:44:56 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

chris

i'm looking for a way to get the hash of a file i'm not picky how as it only so that i can see when they have changed. so any ideas how i can get the hash of a file?

thanks in advaced
chris

Ionic Wind Support Team

Ionic Wind Support Team

chris

i would like to do it through code as i need t use it in a larger program

pistol350

This may be useful.
You can find it in the codeArchive created by Joske


$INCLUDE "md5.inc"
DECLARE IMPORT, GetCommandLine ALIAS GetCommandLineA (), POINTER

MD5_CTX ctx
STRING hex, user
FLOAT t1, t2
POINTER pcmdline
INT pos
STRING szfile

pcmdline = GetCommandLine()
pos = INSTR(*<STRING>pcmdline, " ")
IF pos
   szfile = LTRIM$(MID$(*<STRING>pcmdline, pos+1))
   IF LEN(szfile) = 0
      PRINT "can't make out the file you want to test on"
      END
   ENDIF
ELSE
   PRINT "can't make out the file you want to test on"
   END
ENDIF

t1 = MILLISECS()
md5_init(ctx)
IF md5_readFile(ctx, szfile)
   hex = md5_digest(ctx)
ELSE
   PRINT "File " + szfile + " not found"
ENDIF
t2 = MILLISECS()
PRINT (t2-t1)/1000.0
PRINT hex
INPUT "any key...", user


and here is the include file to use it with
Regards,

Peter B.