473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

MD5 speedup

Hi group.

Any ideas how I could speed up/streamline the below code? Particuarly,
is there a way to use a progress bar for when it calculates the MD5?
Currently it just looks like it is hung for large files.
Private Function MakeMD5(srcFileName as String)

Dim DBfs As FileStream
Dim byt() As Byte

If (New FileInfo(srcFileName).Exists) Then

Try
Dim md5 As New MD5CryptoServiceProvider

DBfs = File.Open(srcFileName, FileMode.Open,
_FileAccess.Read, FileShare.ReadWrite)

byt = md5.ComputeHash(DBfs)

Return (BitConverter.ToString(byt))

Catch ex As Exception

Msgbox(ex.Message)

Finally '

If (Not IsNothing(DBfs)) Then DBfs.Close()

End Try

End If

End Function
--

Daniel
MCSE, MCP+I, MCP in Windows 2000/NT

--------------------------------------
remove the 2nd madrid from my mail address to contact me.
Nov 21 '05 #1
4 1427
Don
Since System.Security.Cryptography.MD5.ComputeHash() is doing all the work,
I don't think there's much more you can do.

However, System.Security.Cryptography.MD5.ComputeHash() also accepts a Byte
array. I doubt you would see any sort of performance increase by loading
the file into a byte array yourself and then passing that to ComputeHash(),
but it's something to try.

If you want to have a progress bar increment with this, then you'll have to
write a function that will compute the hash yourself. ComputeHash() doesn't
appear to raise any trappable progress events.

- Don

"Daniel" <da****@madridmadridsoleado.com> wrote in message
news:e$*************@TK2MSFTNGP15.phx.gbl...
Hi group.

Any ideas how I could speed up/streamline the below code? Particuarly,
is there a way to use a progress bar for when it calculates the MD5?
Currently it just looks like it is hung for large files.
Private Function MakeMD5(srcFileName as String)

Dim DBfs As FileStream
Dim byt() As Byte

If (New FileInfo(srcFileName).Exists) Then

Try
Dim md5 As New MD5CryptoServiceProvider

DBfs = File.Open(srcFileName, FileMode.Open,
_FileAccess.Read, FileShare.ReadWrite)

byt = md5.ComputeHash(DBfs)

Return (BitConverter.ToString(byt))

Catch ex As Exception

Msgbox(ex.Message)

Finally '

If (Not IsNothing(DBfs)) Then DBfs.Close()

End Try

End If

End Function
--

Daniel
MCSE, MCP+I, MCP in Windows 2000/NT

--------------------------------------
remove the 2nd madrid from my mail address to contact me.

Nov 21 '05 #2
Don wrote:
Since System.Security.Cryptography.MD5.ComputeHash() is doing all the work,
I don't think there's much more you can do.

However, System.Security.Cryptography.MD5.ComputeHash() also accepts a Byte
array. I doubt you would see any sort of performance increase by loading
the file into a byte array yourself and then passing that to ComputeHash(),
but it's something to try.

If you want to have a progress bar increment with this, then you'll have to
write a function that will compute the hash yourself. ComputeHash() doesn't
appear to raise any trappable progress events.

- Don

"Daniel" <da****@madridmadridsoleado.com> wrote in message
news:e$*************@TK2MSFTNGP15.phx.gbl...
Hi group.

Any ideas how I could speed up/streamline the below code? Particuarly,
is there a way to use a progress bar for when it calculates the MD5?
Currently it just looks like it is hung for large files.
Private Function MakeMD5(srcFileName as String)

Dim DBfs As FileStream
Dim byt() As Byte

If (New FileInfo(srcFileName).Exists) Then

Try
Dim md5 As New MD5CryptoServiceProvider

DBfs = File.Open(srcFileName, FileMode.Open,
_FileAccess.Read, FileShare.ReadWrite)

byt = md5.ComputeHash(DBfs)

Return (BitConverter.ToString(byt))

Catch ex As Exception

Msgbox(ex.Message)

Finally '

If (Not IsNothing(DBfs)) Then DBfs.Close()

End Try

End If

End Function
--

Daniel
MCSE, MCP+I, MCP in Windows 2000/NT

--------------------------------------
remove the 2nd madrid from my mail address to contact me.



I thought about doing it via a stream as this will at least allow me to
draw something on the screen. Any ideas how to do this?

Thanks.

--

Daniel
MCSE, MCP+I, MCP in Windows 2000/NT

--------------------------------------
remove the 2nd madrid from my mail address to contact me.
Nov 21 '05 #3
Don

"Daniel" <da****@madridmadridsoleado.com> wrote in message
news:uC**************@TK2MSFTNGP10.phx.gbl...
I thought about doing it via a stream as this will at least allow me to
draw something on the screen. Any ideas how to do this?


I've never done it, but I did a quick search and found an MD5 project here:

http://www.frez.co.uk/freecode.htm#md5

It's written in VB, but it should be easy to convert to VB.NET

- Don
Nov 21 '05 #4
since the idea is to show that something is happening and that the app
is not hung, you may want to consider an indeterminate progress bar.
microsoft published a c# sample for this here:
http://www.microsoft.com/downloads/d...displaylang=en

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: andrewpalumbo | last post by:
I'm trying to write some code which will split up a vector into two halves and run a method on the objects in the vector using two seperate threads. I was hoping to see a near linear speedup on an...
23
by: Mark Dickinson | last post by:
I have a simple 192-line Python script that begins with the line: dummy0 = 47 The script runs in less than 2.5 seconds. The variable dummy0 is never referenced again, directly or indirectly,...
8
by: TM | last post by:
I have a small application that displays records from an access mdb into two datagrids and am looking to see if it is possible to speedup the loadtime somehow. In my formload I am filling my...
12
by: Lars Schouw | last post by:
All, Does anyone know how much performance speedup I can expect by using 64 bit C++ / Windows XP 64 bit over the 32 bit versions? Did anyone test this under Visual Studio 2005 or Intel C++...
4
by: Galen Somerville | last post by:
My VB2005 app gets real time Heart sounds and an ECG from a USB device. I'm looking for a way to speed up the drawing of the traces on the screen. In the following code the routine GetSounds...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.