From 860676fa5b40a1904478151e9b4934c004e7db63 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Mon, 7 Oct 2019 11:18:13 -0700 Subject: Implement Bundle build --- .../Bundles/BundleHashAlgorithm.cs | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/WixToolset.Core.Burn/Bundles/BundleHashAlgorithm.cs (limited to 'src/WixToolset.Core.Burn/Bundles/BundleHashAlgorithm.cs') diff --git a/src/WixToolset.Core.Burn/Bundles/BundleHashAlgorithm.cs b/src/WixToolset.Core.Burn/Bundles/BundleHashAlgorithm.cs new file mode 100644 index 00000000..3a71ed4c --- /dev/null +++ b/src/WixToolset.Core.Burn/Bundles/BundleHashAlgorithm.cs @@ -0,0 +1,30 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Core.Burn.Bundles +{ + using System.IO; + using System.Security.Cryptography; + using System.Text; + + internal static class BundleHashAlgorithm + { + public static string Hash(FileInfo fileInfo) + { + byte[] hashBytes; + + using (var managed = new SHA1Managed()) + using (var stream = fileInfo.OpenRead()) + { + hashBytes = managed.ComputeHash(stream); + } + + var sb = new StringBuilder(hashBytes.Length * 2); + for (var i = 0; i < hashBytes.Length; i++) + { + sb.AppendFormat("{0:X2}", hashBytes[i]); + } + + return sb.ToString(); + } + } +} -- cgit v1.2.3-55-g6feb