473,395 Members | 1,941 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,395 software developers and data experts.

calculating MD5 from binary file

Me
Does anyone have a VB.Net sample for calculating the MD5 value from a binary
file? Had it a while ago but formated the drive by accident... :\

J
Nov 20 '05 #1
2 4176
Me
Found the answer(Murphy must be laughing at me) ;) I've cobbled together a
sample using the following solution (I think it's in C#):

http://www.gotdotnet.com/Community/U...4-ddc38d8d6fab

Here are my samples:

Quick and dirty way:

Sub QDMD5(strPath as String)
Dim fs As New FileStream(strPath, FileMode.Open,
FileAccess.Read)
Dim bt As Byte() = New
Security.Cryptography.MD5CryptoServiceProvider().C omputeHash(fs)
Console.WriteLine(BitConverter.ToString(bt))
fs.Close()
End Sub

Long way(may be slightly more readable).

Sub LWMD5(strPath as String)
Dim fs2 As FileStream
Dim bt2 As Byte()
Dim MDCheck As New Security.Cryptography.MD5CryptoServiceProvider

fs2 = File.Open(strPath , FileMode.Open, FileAccess.Read)
bt2 = check.ComputeHash(fs2)
Console.WriteLine(BitConverter.ToString(bt2))
fs2.Close()
End Sub

YMMV :)

Yeah I know meaningful variables would be nice... I'll document it tomorrow.
;) (sorry for the rambling I'm suffering from a NyQuil hangover :) )

"Me" <me@here.com> wrote in message
news:pG*******************@twister01.bloor.is.net. cable.rogers.com...
Does anyone have a VB.Net sample for calculating the MD5 value from a binary file? Had it a while ago but formated the drive by accident... :\

J

Nov 20 '05 #2
Hi Me,

Thanks for the code. Someone's just come in asking how to - gues what -
calculate MD5 from a file!!

Cheers,
Fergus
Nov 20 '05 #3

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

Similar topics

5
by: Ron Adam | last post by:
Hi, I'm having fun learning Python and want to say thanks to everyone here for a great programming language. Below is my first Python program (not my first program) and I'd apreciate any...
13
by: yaipa | last post by:
What would be the common sense way of finding a binary pattern in a ..bin file, say some 200 bytes, and replacing it with an updated pattern of the same length at the same offset? Also, the...
12
by: Ola Natvig | last post by:
Hi all Does anyone know of a fast way to calculate checksums for a large file. I need a way to generate ETag keys for a webserver, the ETag of large files are not realy nececary, but it would be...
11
by: 193.123.19.116 [Daz] | last post by:
Is there any way using C library functions to get the size of a directory and its contents (without resorting to using a shell command)? ================================== Poster's IP...
9
by: Ching-Lung | last post by:
Hi all, I try to create a tool to check the delta (diff) of 2 binaries and create the delta binary. I use binary formatter (serialization) to create the delta binary. It works fine but the...
12
by: Adam J. Schaff | last post by:
I am writing a quick program to edit a binary file that contains file paths (amongst other things). If I look at the files in notepad, they look like: ...
4
by: Mahesh S | last post by:
Hi I am writing a sql query (added below) to calulate percentage. Its returning an integer value whereas I would like to get a float value (with 2 decimal precision). The query is: ...
8
by: brasilino | last post by:
Hi Folks: I'm trying to calculating a substring length directly from pointer address, like this: char *e = NULL, *s = NULL; int len = 0; s = strchr (url,'.'); e = strrchr (url,'?');
16
by: Erwin Moller | last post by:
Why is a binary file executable? Is any binary file executable? Is only binary file executable? Are all executable files binary? What is the connection between the attribute of binary and that of...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
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.