[Mono-list] Issue with SHA256 on Mono

Sebastien Pouliot sebastien.pouliot at gmail.com
Tue May 5 14:58:50 EDT 2009


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





More information about the Mono-list mailing list