[Mono-list] Issue with SHA256 on Mono

Varun Rai varun.wipro at gmail.com
Tue May 5 21:41:35 EDT 2009


Hi Sebastien,

Thanks for your reply. I managed to fix the problem. It was not with the
file. The problem was with the byte[] recd on windows pc. The byte[] got
corrupted somehow. Because i manually compared the byte array in mono and
the other one in windows(.net) , they were the same.

Thanks again.
Varun


On Wed, May 6, 2009 at 2:58 AM, Sebastien Pouliot <
sebastien.pouliot at gmail.com> wrote:

> On Tue, 2009-05-05 at 04:00 -0700, Varun Rai wrote:
> > I computed a hash for the file stream in mono. And the same method i used
> on
> > windows to compute the hash of the same file. I get two different byte
> > arrays. I tried to look into the problem but till now no solution. Does
> any
> > one know why this happens?
> >
> > Thanks,
> > Varun
> >
> > public static byte[] GetFileHash(string fileName)
> >         {
> >             byte[] dataHash = null;
> >
> >             FileStream fs = new
> > FileStream(fileName,FileMode.Open,FileAccess.Read,FileShare.Read);
> >                       byte[] data = new byte[fs.Length];
> >
> >                       fs.Read(data,0, Convert.ToInt32(fs.Length));
> >                       fs.Close();
> >
> >                       SHA256 sha = new SHA256Managed();
> >                       dataHash = sha.ComputeHash(data);
> >
> >             return dataHash;
> >         }
>
> Are you sure both files are truly identical (e.g. corrupted when
> copied) ? like have you run md5sum or sha1sum on both computers ?
>
> Next what happens if you change SHA256 for other hash algorithms, like
> SHA1, MD5, SHA384, SHA512... do you get the same results ? or something
> different ?
>
> If this is similar for all but SHA256 then please open a bug report on
> bugzilla.novell.com
>
> Thanks
> Sebastien
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20090506/a066b2ba/attachment.html 


More information about the Mono-list mailing list