IonicWind Software

IWBasic => General Questions => Topic started by: chris on September 03, 2008, 08:44:56 PM

Title: getting MD5 or sha-1 hash code
Post by: chris on September 03, 2008, 08:44:56 PM
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
Title: Re: getting MD5 or sha-1 hash code
Post by: Ionic Wind Support Team on September 03, 2008, 09:10:23 PM
A utility or through code?

tjs, a user of our forums, wrote a utility:

http://www.download.com/MD5-Checker/3000-2092_4-10410639.html

Paul.
Title: Re: getting MD5 or sha-1 hash code
Post by: chris on September 03, 2008, 09:26:23 PM
i would like to do it through code as i need t use it in a larger program
Title: Re: getting MD5 or sha-1 hash code
Post by: pistol350 on September 04, 2008, 03:58:54 AM
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