views:

176

answers:

1

How can I get the MD5 hex hash for a file using VBA?

I need a version that works for a file.

Something as simple as this Python code:

import hashlib

def md5_for_file(fileLocation, block_size=2**20):
    f = open(fileLocation)
    md5 = hashlib.md5()
    while True:
        data = f.read(block_size)
        if not data:
            break
        md5.update(data)
    f.close()
    return md5.hexdigest()

But in VBA.

+2  A: 

http://www.di-mgt.com.au/crypto.html#MD5

Stuart Dunkeld
That only makes the hash of a string. If a file has 700mb, I can't put it all in one string and do the md5 hash on it. So, is there a md5 hash for files version or another solution? :P
aF