I've nearly finished my personal auto updater and the only thing left to
implement is a hash check against the downloaded file to make sure it's
good before extracting it. Right now I havn't released it so I've
tested that the selected update components download correctly and
extract and that the program starts back up as the new version...
I've googled for about a half hour and couldn't figure out how to
generate an MD5 hash for both storing in my website's database and for
generating on the downloaded file to compare against the xml file I
download in the first place in order to download the updates.
So, does anyone have a quick tutorial on how to generate an MD5 hash on
a file?
Thanks in advance,
Benny 4 2712
is this what i should be doing?
public class MD5Check
{
private string _hash;
private string _file;
public MD5Check(string file, string hash)
{
_hash = hash;
_file = file;
}
public bool Verify()
{
MD5CryptoServic eProvider csp = new MD5CryptoServic eProvider();
if (File.Exists(_f ile))
{
FileStream fs = File.OpenRead(_ file);
byte[] fileHash = csp.ComputeHash (fs);
fs.Close();
// convert to string
string computed = BitConverter.To String(fileHash );
if (computed == _hash)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
}
Benny,
Have you checked out the MD5CryptoServic eProvider class? It takes a
byte array and hashes the contents.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Benny Raymond" <be***@pocketro cks.com> wrote in message
news:uq******** ******@TK2MSFTN GP15.phx.gbl... I've nearly finished my personal auto updater and the only thing left to implement is a hash check against the downloaded file to make sure it's good before extracting it. Right now I havn't released it so I've tested that the selected update components download correctly and extract and that the program starts back up as the new version...
I've googled for about a half hour and couldn't figure out how to generate an MD5 hash for both storing in my website's database and for generating on the downloaded file to compare against the xml file I download in the first place in order to download the updates.
So, does anyone have a quick tutorial on how to generate an MD5 hash on a file?
Thanks in advance, Benny
Hi,
check this:
.....
using System.Security .Cryptography;
.....
FileStream fs = new FileStream(file name, FileMode.Open, FileAccess.Read ,
FileShare.Read) ;
byte [] HashCode = new MD5CryptoServic eProvider().Com puteHash(fs);
fs.Close();
....
at this point HashCode byte array has the code. Once u receive the file,
perform this operations again and check against the has bits generated for
the received file.
Ab. http://joehacker.blogspot.com
"Benny Raymond" <be***@pocketro cks.com> wrote in message
news:uq******** ******@TK2MSFTN GP15.phx.gbl... I've nearly finished my personal auto updater and the only thing left to implement is a hash check against the downloaded file to make sure it's good before extracting it. Right now I havn't released it so I've tested that the selected update components download correctly and extract and that the program starts back up as the new version...
I've googled for about a half hour and couldn't figure out how to generate an MD5 hash for both storing in my website's database and for generating on the downloaded file to compare against the xml file I download in the first place in order to download the updates.
So, does anyone have a quick tutorial on how to generate an MD5 hash on a file?
Thanks in advance, Benny This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Roy |
last post by:
Hi,
I have a problem that I have been working with for a while.
I need to be able from server side (asp.net) to detect that the file i'm
streaming down to the client is saved completely/succsessfully on the
client's computer before updating some metadata on the server (file
downloaded date for instance)
However,
All examples i have tried, and all examples I have found that other people
says works - doesn't work for me :-(
|
by: Dino M. Buljubasic |
last post by:
Hi,
I am using MD5 to hash my passwords and add them to database as hashed.
I have noticed though that some passwords don't get recognized and I suppose
that it happen because hashing might introduce some characters in my
password that are not handled properly by SQL server then.
For example, password 'startreck' works just fine
password 'test' does not
|
by: Kevin Blount |
last post by:
My current site uses a ASP, database driven, ID based system to allow
people to download files they have the right permissions to, as well as
to send an email to them with necessary support links and passwords and
an email to us with 'who did what and when' info.
a typical link from this system might be
http://www.oursite.com/getfile.asp?id=123
My current task is to allows link directly to the file (for a cleaner
|
by: ^MisterJingo^ |
last post by:
Hi all,
I've written some code which allows a user to browse a directory and
any subdirectories it contains. The page which contains this can only
be browsed by users with a certain cookie (the page checks for this
before allowing access).
To stop files being downloaded through a link to them on a server
(potentially allowing unauthorized people access) I've put the
directory containing the files outside of the web root.
This all works...
|
by: Dan D |
last post by:
I have a large install file (an exe) on my web server that people
download and install from. Looking at my log files, I see a lot of
people downloading it, but no way to tell for sure if they completed the
download or cancelled out before it completed. Is there any function in
PHP that would allow the web server to send the file and detect a
completion or cancellation? Or perpahs a javascript/PHP method?
Any help would be greatly...
| |
by: rdemyan via AccessMonster.com |
last post by:
Anyone have any ideas on how to determine when the back-end file (containing
only tables) has been updated with new data.
The date/time of the file won't work because it gets updated to the current
date/time when the back-end file is compacted.
I'm just looking for an easy way to determine when there has been a change to
data in any table in the back-end file.
Maybe something is updated in one of the system tables??
|
by: rpnew |
last post by:
Hi,
I'm very new to PHP and making one project..
what i want to do is .. i want to make a file download facilities thorough which user of my web pages can download selected file. presently i'm using one code (got from internet) i tried to modified it every way but every time file download dialog box opens but it downloads blank file.. neither it checks for file existence.....
any help would be appreciated..
Presently i'm using...
|
by: January Weiner |
last post by:
Hello,
I need to use a hashing function for relatively short strings (roughly 16
characters or less). The data that needs to be accessed via hash is just a
simple int. I just need to look up values in two dimensional matrices each
time that I encounter a pair of these strings.
I would like to keep the code as simple and standard as
possible, but at the same time to have a reasonable performance.
|
by: KevinADC |
last post by:
Note: You may skip to the end of the article if all you want is the perl code.
Introduction
Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script.
What You Need
Any recent...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |