05-06-2010, 05:07 AM
1. This can be used with small files, maybe <10MB. For big files may be not enough memory.
Macro Macro1426
2. This can be used with files of any size.
Macro Macro1431
For 2 you need this function. Create it as member function.
Member function str.FileMD5
Macro Macro1426
2. This can be used with files of any size.
Macro Macro1431
For 2 you need this function. Create it as member function.
Member function str.FileMD5
function $file [flags] ;;flags: 1 hex
;Calculates MD5 hash of a file and stores into this str variable.
;Error if fails.
;EXAMPLE
;str s.FileMD5("$desktop$\test.txt" 1)
;out s
type MD5_CTX i[2] buf[4] !in[64] !digest[16]
dll- cryptdll
,MD5Init MD5_CTX*context
,MD5Update MD5_CTX*context !*data dataLen
,MD5Final MD5_CTX*context
__HFile f.Create(file OPEN_EXISTING GENERIC_READ FILE_SHARE_READ)
str b.all(4096 2)
int nr
MD5_CTX c
MD5Init &c
rep
,if(!ReadFile(f b 4096 &nr 0)) end _s.dllerror
,if(!nr) break
,MD5Update &c b nr
MD5Final &c
this.fromn(&c.digest 16)
if(flags&1) this.encrypt(8)
err+ end _error