Solved

Get  MD5  For Files vb6

Posted on 2004-09-29
6
603 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 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now