Ejemplo n.º 1
0
        public static string GetFileHash(string file)
        {
            var hash = "0";

            if (File.Exists(file))
            {
                var alg = System.Security.Cryptography.HashAlgorithm.Create("MD5");
                using (var stream = File.OpenRead(file))
                {
                    var bytes = alg.ComputeHash(stream);
                    hash = CharUtil.ToHexString(bytes);
                }
            }

            return(hash);
        }