Solved

Get  MD5  For Files vb6

Posted on 2004-09-29
6
638 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

735 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