diff options
Diffstat (limited to 'src/WixToolset.Core/Common.cs')
-rw-r--r-- | src/WixToolset.Core/Common.cs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/WixToolset.Core/Common.cs b/src/WixToolset.Core/Common.cs index 19c77368..7a321d29 100644 --- a/src/WixToolset.Core/Common.cs +++ b/src/WixToolset.Core/Common.cs | |||
@@ -329,21 +329,22 @@ namespace WixToolset.Core | |||
329 | /// <returns>The generated identifier.</returns> | 329 | /// <returns>The generated identifier.</returns> |
330 | public static string GenerateIdentifier(string prefix, params string[] args) | 330 | public static string GenerateIdentifier(string prefix, params string[] args) |
331 | { | 331 | { |
332 | string stringData = String.Join("|", args); | 332 | string base64; |
333 | byte[] data = Encoding.UTF8.GetBytes(stringData); | ||
334 | 333 | ||
335 | // hash the data | 334 | using (var sha1 = new SHA1CryptoServiceProvider()) |
336 | byte[] hash; | ||
337 | using (SHA1 sha1 = new SHA1CryptoServiceProvider()) | ||
338 | { | 335 | { |
339 | hash = sha1.ComputeHash(data); | 336 | var combined = String.Join("|", args); |
337 | var data = Encoding.UTF8.GetBytes(combined); | ||
338 | var hash = sha1.ComputeHash(data); | ||
339 | base64 = Convert.ToBase64String(hash); | ||
340 | } | 340 | } |
341 | 341 | ||
342 | // Build up the identifier. | 342 | var identifier = new StringBuilder(32); |
343 | StringBuilder identifier = new StringBuilder(35, 35); | ||
344 | identifier.Append(prefix); | 343 | identifier.Append(prefix); |
345 | identifier.Append(Convert.ToBase64String(hash).TrimEnd('=')); | 344 | identifier.Append(base64); |
346 | identifier.Replace('+', '.').Replace('/', '_'); | 345 | identifier.Length -= 1; // removes the trailing '=' from base64 |
346 | identifier.Replace('+', '.'); | ||
347 | identifier.Replace('/', '_'); | ||
347 | 348 | ||
348 | return identifier.ToString(); | 349 | return identifier.ToString(); |
349 | } | 350 | } |