Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Leuven, Vlaanderen, Belgium
    Posts
    312
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Hi,
    I would like to calculate a file's MD5 hash/checksum using a VBA procedure in MS Access without needing a DLL or other library (which I would have to distribute with the database, and I would like to keep it as simple for the users as possible)...
    Is this possible?
    Hasse

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts
    Does MD5 for Visual Basic (VB) do what you want?

  3. #3
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Leuven, Vlaanderen, Belgium
    Posts
    312
    Thanks
    5
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='762548' date='01-Mar-2009 01:58']Does MD5 for Visual Basic (VB) do what you want?[/quote]Thanks Hans! Yes it does .

    Now... next problem: unfortunately it's too slow for large files, yields an error with a 'regular' file,...

    So (before spending time figuring out workarounds & debugging) I tried using the Shell function & a small freeware MD5 generator of DiamondCS (page includes screenshot).
    I put this generator in the same folder along with my database... and 'run' it with these lines (in order to yield the hash for a file called plan.htm which resides in the same folder too):
    Code:
    Private Sub MD5_Click()
    Dim str As String
    str = Shell(CurrentProject.Path & "\md5.exe " & CurrentProject.Path & "\plan.htm")
    MsgBox str
    end Sub
    The MgsBox returns a (every time different) number instead of the hash string.
    Is my Shell command wrong? Or is there something else wrong here? (Or should I contact the creator of this tool?)
    I feel pretty much like a greeny...
    Hasse

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts
    [quote name='hasse' post='762721' date='02-Mar-2009 03:50'][/quote]
    The result of Shell is not the return value of the application that you start, but its TaskID, i.e. the number that Windows uses to identify it.
    You could write the return value to a text file, then open the text file. The following is air code:

    Dim f As Integer
    Dim strLine As String
    Shell "cmd /c " & Chr(34) & CurrentProject.Path & "\md5.exe " & _
    CurrentProject.Path & "\plan.htm > " & CurrentProject.Path& "\temp.txt" & Chr(34)
    f = FreeFile
    Open CurrentProject.Path& "\temp.txt" For Input As #f
    Line Input #f, strLine
    Close #f
    Kill CurrentProject.Path& "\temp.txt"
    ' strLine should now contain the MD5 value

  5. #5
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Leuven, Vlaanderen, Belgium
    Posts
    312
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Thanks Hans. I tried it but the 'open' line yielded an error 53 (can't find file), also when I for example created such a file myself before running the procedure. I'll ask a collegue at work if he can fix it and let you know.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •