예제 #1
0
        public static string GetHash(string content)
        {
            List <string> filteredContent = string.IsNullOrEmpty(content)
                                         ? new List <string>()
                                         :  content.Replace("\r", string.Empty)
                                            .Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries)
                                            .Where(line => !line.Contains("// outputid:"))
                                            .ToList();

            // Strip header
            while ((filteredContent.FirstOrDefault()?.StartsWith("//") ?? false) || (filteredContent.FirstOrDefault()?.StartsWith("/*") ?? false))
            {
                filteredContent.RemoveAt(0);
            }
            if (filteredContent.Count == 0)
            {
                return(null);
            }
            return(Sha512.Create(string.Join(Environment.NewLine, filteredContent)).ToString());
        }