Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Get  MD5  For Files vb6

Posted on 2004-09-29
6
Medium Priority
?
675 Views
Last Modified: 2009-12-16
Hello Experts

Id like to get the md5 of files instead of
strings using http://www.frez.co.uk/MD5.zip

how can i do this ?

Can you place a text box for the file input and text box for the md5 output

thankyou eperts

0
Comment
Question by:Jimmyx1000
  • 2
  • 2
6 Comments
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12185072
Not much difficult to do. But are you sure you want to do that? Generating MD5 digest for a large file may easily take hours.

Code is simple.

Dim filehandle, buffer, filename

filehandle = freefile
open filename for input as filehandle
input filehandle#, buffer

Now compute the MD5 on buffer.
0
 

Author Comment

by:Jimmyx1000
ID: 12186856
Hmmmm

Can you tell me where i place this code

thanks
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12189562
(1) Add a text box to your form to hold the name of the file.
(2) Or you can add a Common Dialog control to the form and use it for getting the filename. I think method 1 will be easier for you.

The above code goes into the click event of the button. You can remove the existing code from the button.
0
 

Author Comment

by:Jimmyx1000
ID: 12191652
in your code above there is no reference to a text1.text box

Please can you give me the exact code and where to place it

Im a beginner with this stuff


0
 
LVL 1

Accepted Solution

by:
Lycaon earned 2000 total points
ID: 12218966
Jimmyx1000:

NOTE:  The MD5 class you are using is NOT built to calculate MD5 checksums on large files.  The code below works by reading all of the file at once into a byte array.  Trying to select a 50 MB or bigger file is a **bad** idea, so use at your own risk.  It is a fully functional program though.

A good way of doing this is below:

Place a Label on your form, leave it's name as Label1
Place a DriveList on your form, leave it's name as Drive1
Place a DirList on your form, leave it's name as Dir1
Place a FileList on your form, leave it's name as File1

These controls are all in the component toolbar to the left of the IDE Window.

Delete ALL code out of the form, and paste this:

'--------------------------------------------------------------------
Option Explicit

Dim clsMD5 As New CMD5

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub

Private Sub File1_Click()
Dim b As String

Open File1.Path For Binary Access Read As #1
s = Input(1, LOF(1))
Close #1

Label1.Caption = clsMD5.MD5(b)
End Sub
'----------------------------------------------------------
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question