-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Client Telemetry : Refactors code to compute hash of VM ID and Proces…
…s Name information (#3376) * hashed vmid and processname * appended hashedvmid * dummycommit * use string format * renamed util class name * fix refrence Co-authored-by: Sourabh Jain <sourabhjain@microsoft.com>
- Loading branch information
1 parent
83d9f70
commit 1151f55
Showing
7 changed files
with
60 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.Util | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
|
||
internal class HashingExtension | ||
{ | ||
/// <summary> | ||
/// Hash a passed Value | ||
/// </summary> | ||
/// <param name="rawData"></param> | ||
/// <returns>hashed Value</returns> | ||
internal static string ComputeHash(string rawData) | ||
{ | ||
if (string.IsNullOrEmpty(rawData)) | ||
{ | ||
throw new ArgumentNullException(nameof(rawData)); | ||
} | ||
|
||
// Create a SHA256 | ||
using (SHA256 sha256Hash = SHA256.Create()) | ||
{ | ||
// ComputeHash - returns byte array | ||
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(rawData)); | ||
Array.Resize(ref bytes, 16); | ||
|
||
// Convert byte array to a string | ||
return new Guid(bytes).ToString(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters