public const string MERKLE_EMPTY = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";\r
\r
\r
- //public static string CalculateMD5(FileSystemInfo info)\r
- //{\r
- // if (info==null)\r
- // throw new ArgumentNullException("info");\r
- // if (String.IsNullOrWhiteSpace(info.FullName))\r
- // throw new ArgumentException("info.FullName is empty","info");\r
- // Contract.EndContractBlock();\r
-\r
- // if (info is DirectoryInfo)\r
- // return MD5_EMPTY;\r
-\r
- // return CalculateMD5(info.FullName);\r
- //}\r
-\r
- //public static string CalculateMD5(string path)\r
- //{\r
- // if (String.IsNullOrWhiteSpace(path))\r
- // throw new ArgumentNullException("path");\r
- // Contract.EndContractBlock();\r
-\r
- // //DON'T calculate hashes for folders\r
- // if (Directory.Exists(path))\r
- // return "";\r
- // //TODO: Replace with MD5BlockCalculator\r
- // string hash;\r
- // using (var hasher = new MessageDigestContext(MessageDigest.CreateByName("md5")))\r
- // using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, BufferSize, true))\r
- // {\r
- // var buffer = new byte[BufferSize];\r
- // hasher.Init();\r
- // int read;\r
- // do\r
- // { \r
- // read = stream.Read(buffer, 0, buffer.Length); \r
- // if (read==buffer.Length)\r
- // {\r
- // hasher.Update(buffer); \r
- // }\r
- // else\r
- // {\r
- // var block = new byte[read];\r
- // Buffer.BlockCopy(buffer, 0, block, 0, read);\r
- // hasher.Update(block); \r
- // }\r
- // } while (read>0);\r
- // var hashBytes = hasher.DigestFinal();\r
- // hash = hashBytes.ToHashString();\r
- // }\r
- // return hash;\r
- //}\r
-\r
- \r
-/*\r
- public static string BytesToString(byte[] hashBytes)\r
- {\r
- var shb=new SoapHexBinary(hashBytes);\r
- return shb.ToString();\r
- \r
- }\r
-\r
-\r
- public static byte[] StringToBytes(string hash)\r
- {\r
- var shb=SoapHexBinary.Parse(hash);\r
- return shb.Value;\r
- }\r
-*/\r
-\r
public static byte[] ToBytes(this string hash)\r
{\r
var shb = SoapHexBinary.Parse(hash);\r