public void CalculateValueHash() { using var ms = new MemoryStream(); using var writer = new BinaryWriter(ms, Encoding.UTF8, true); writer.Write(Id.ToByteArray()); writer.Write(No); writer.Write(Description); writer.Write(Details); writer.Write(MoreInfo); writer.Write(AddedToRoadmap.ToBinary()); writer.Write(LastModified.ToBinary()); writer.Write(Release); writer.Write((int)EditType); writer.Write((int)Status); foreach (var featureTag in FeatureTags.OrderBy(x => x.Tag.Category).ThenBy(x => x.Tag.Name)) { writer.Write((int)featureTag.Tag.Category); writer.Write(featureTag.Tag.Name); } writer.Flush(); writer.Close(); ms.Position = 0; var hash = SHA1.Create().ComputeHash(ms); ValuesHash = HashExtensions.ByteArrayToHexViaLookup32Unsafe(hash); }
public static string GenerateFeatureHashListHash(this IEnumerable <Feature> features) { using var ms = new MemoryStream(); using var sw = new StreamWriter(ms, Encoding.UTF8); foreach (var feature in features) { sw.Write(feature.ValuesHash); } ms.Position = 0; using var sha1 = SHA1.Create(); var hash = sha1.ComputeHash(ms); return(HashExtensions.ByteArrayToHexViaLookup32Unsafe(hash)); }