Click here to Skip to main content
15,889,900 members
Home / Discussions / C#
   

C#

 
AnswerRe: List to xml Pin
harold aptroot19-Jun-09 3:52
harold aptroot19-Jun-09 3:52 
GeneralRe: List to xml Pin
zeeShan anSari19-Jun-09 4:08
zeeShan anSari19-Jun-09 4:08 
GeneralRe: List to xml Pin
harold aptroot19-Jun-09 4:13
harold aptroot19-Jun-09 4:13 
GeneralRe: List to xml Pin
zeeShan anSari19-Jun-09 4:25
zeeShan anSari19-Jun-09 4:25 
GeneralRe: List to xml Pin
harold aptroot19-Jun-09 4:33
harold aptroot19-Jun-09 4:33 
QuestionFile Byte[] Conversion to String for MD5 Hash Generation Pin
JimmyHeaddon19-Jun-09 3:39
JimmyHeaddon19-Jun-09 3:39 
AnswerRe: File Byte[] Conversion to String for MD5 Hash Generation Pin
harold aptroot19-Jun-09 3:45
harold aptroot19-Jun-09 3:45 
AnswerRe: File Byte[] Conversion to String for MD5 Hash Generation [modified] Pin
Mirko198019-Jun-09 4:02
Mirko198019-Jun-09 4:02 
Why you are converting the byte array into a base-64 string and then calculating the hash on the string? You can calculate the hash directly on the byte array, probably that is the reason because your hash in incorrect.
Also, why you are using Regex.Replace instead of the regular string.Replace?

For your 2nd problem, you can calculate the hash on a stream instead than on a byte array (that has a limit of 2Gb).

The following code summarizes what you have to do:

public static string MD5Hash(string filename)
{
    System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();

    using (Stream stream = new FileStream(filename, FileMode.Open, FileAccess.Read))
    {
        return BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "");
    }    
}


Much simpler, don't you think? Wink | ;)

modified on Friday, June 19, 2009 10:19 AM

AnswerRe: File Byte[] Conversion to String for MD5 Hash Generation Pin
JimmyHeaddon19-Jun-09 4:27
JimmyHeaddon19-Jun-09 4:27 
AnswerRe: File Byte[] Conversion to String for MD5 Hash Generation Pin
Luc Pattyn19-Jun-09 4:02
sitebuilderLuc Pattyn19-Jun-09 4:02 
Questionconnection string in a file Pin
Adekolurejo19-Jun-09 3:38
Adekolurejo19-Jun-09 3:38 
AnswerRe: connection string in a file Pin
SeMartens19-Jun-09 3:44
SeMartens19-Jun-09 3:44 
AnswerRe: connection string in a file Pin
stancrm19-Jun-09 3:47
stancrm19-Jun-09 3:47 
GeneralRe: connection string in a file Pin
harold aptroot19-Jun-09 4:00
harold aptroot19-Jun-09 4:00 
GeneralRe: connection string in a file Pin
Adekolurejo19-Jun-09 4:30
Adekolurejo19-Jun-09 4:30 
GeneralRe: connection string in a file Pin
harold aptroot19-Jun-09 4:34
harold aptroot19-Jun-09 4:34 
AnswerRe: connection string in a file Pin
meeram39519-Jun-09 3:48
meeram39519-Jun-09 3:48 
AnswerRe: connection string in a file [modified] Pin
kstls20-Jun-09 11:03
kstls20-Jun-09 11:03 
QuestionUrgent Mail Sending Problem Pin
dev sheoran19-Jun-09 2:09
dev sheoran19-Jun-09 2:09 
AnswerRe: Urgent Mail Sending Problem Pin
Not Active19-Jun-09 2:13
mentorNot Active19-Jun-09 2:13 
GeneralRe: Urgent Mail Sending Problem Pin
dev sheoran19-Jun-09 2:30
dev sheoran19-Jun-09 2:30 
GeneralRe: Urgent Mail Sending Problem Pin
Nagy Vilmos19-Jun-09 3:22
professionalNagy Vilmos19-Jun-09 3:22 
JokeRe: Urgent Mail Sending Problem [modified] Pin
musefan19-Jun-09 3:24
musefan19-Jun-09 3:24 
GeneralRe: Urgent Mail Sending Problem Pin
EliottA19-Jun-09 3:38
EliottA19-Jun-09 3:38 
GeneralRe: Urgent Mail Sending Problem Pin
musefan19-Jun-09 3:40
musefan19-Jun-09 3:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.