aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.Burn/Bundles/BundleHashAlgorithm.cs
diff options
context:
space:
mode:
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}