Exemplo n.º 1
0
        public string FileFingerPrint(string fileName)
        {
            fileName = FileManagerSecure.NormalizePath(fileName);
#if LFE_DEBUG
            var sw = new Stopwatch();
            sw.Start();
#endif
            var inBytes = FileManagerSecure.ReadAllBytes(fileName);
#if LFE_DEBUG
            sw.Stop();
            SuperController.LogMessage($"fingerprint: read {fileName} took: {sw.ElapsedMilliseconds}ms");
            sw.Reset();
            sw.Start();
#endif
            var outBytes = _md5.ComputeHash(inBytes);
            var sb       = new StringBuilder();
            for (var i = 0; i < outBytes.Length; i++)
            {
                sb.Append(outBytes[i].ToString("X2"));
            }
            var print = sb.ToString();
#if LFE_DEBUG
            sw.Stop();
            SuperController.LogMessage($"fingerprint: hash {fileName} took: {sw.ElapsedMilliseconds}ms");
#endif
            return(print);
        }