Solved

Get  MD5  For Files vb6

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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month7 days, left to enroll

622 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