Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Get  MD5  For Files vb6

Posted on 2004-09-29
6
Medium Priority
?
668 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 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Suggested Courses

664 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