aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.Burn/Bundles/BundleHashAlgorithm.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2019-10-07 11:18:13 -0700
committerRob Mensching <rob@firegiant.com>2019-10-07 11:59:14 -0700
commit860676fa5b40a1904478151e9b4934c004e7db63 (patch)
tree83fabd53f2a68dcf56bc8da66d88e115af3764b0 /src/WixToolset.Core.Burn/Bundles/BundleHashAlgorithm.cs
parent3b98dac62b47d590f3465985362d6e6fd100b1c0 (diff)
downloadwix-860676fa5b40a1904478151e9b4934c004e7db63.tar.gz
wix-860676fa5b40a1904478151e9b4934c004e7db63.tar.bz2
wix-860676fa5b40a1904478151e9b4934c004e7db63.zip
Implement Bundle build
Diffstat (limited to 'src/WixToolset.Core.Burn/Bundles/BundleHashAlgorithm.cs')
-rw-r--r--src/WixToolset.Core.Burn/Bundles/BundleHashAlgorithm.cs30
1 files changed, 30 insertions, 0 deletions
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 @@
1// 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.
2
3namespace WixToolset.Core.Burn.Bundles
4{
5 using System.IO;
6 using System.Security.Cryptography;
7 using System.Text;
8
9 internal static class BundleHashAlgorithm
10 {
11 public static string Hash(FileInfo fileInfo)
12 {
13 byte[] hashBytes;
14
15 using (var managed = new SHA1Managed())
16 using (var stream = fileInfo.OpenRead())
17 {
18 hashBytes = managed.ComputeHash(stream);
19 }
20
21 var sb = new StringBuilder(hashBytes.Length * 2);
22 for (var i = 0; i < hashBytes.Length; i++)
23 {
24 sb.AppendFormat("{0:X2}", hashBytes[i]);
25 }
26
27 return sb.ToString();
28 }
29 }
30}