Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ protected override void EndProcessing()
{
byte[] bytehash = ComputeHash(InputStream);

string hash = BitConverter.ToString(bytehash).Replace("-", string.Empty);
string hash = Convert.ToHexString(bytehash);
WriteHashResult(Algorithm, hash, string.Empty);
}
}
Expand All @@ -177,7 +177,7 @@ private bool ComputeFileHash(string path, out string hash)
openfilestream = File.OpenRead(path);
byte[] bytehash = ComputeHash(openfilestream);

hash = BitConverter.ToString(bytehash).Replace("-", string.Empty);
hash = Convert.ToHexString(bytehash);
}
catch (FileNotFoundException ex)
{
Expand Down
2 changes: 1 addition & 1 deletion src/System.Management.Automation/security/CatalogHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ internal static string CalculateFileHash(string filePath, string hashAlgorithm)
_cmdlet.ThrowTerminatingError(errorRecord);
}

hashValue = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
hashValue = Convert.ToHexString(hashBytes);
}

return hashValue;
Expand Down
2 changes: 1 addition & 1 deletion src/System.Management.Automation/utils/PsUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ internal static byte[] ComputeHash(byte[] buffer)
internal static string ComputeHash(string input)
{
byte[] hashBytes = ComputeHash(Encoding.UTF8.GetBytes(input));
return BitConverter.ToString(hashBytes).Replace("-", string.Empty);
return Convert.ToHexString(hashBytes);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/utils/tracing/PSEtwLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ internal static void LogAnalyticVerbose(PSEventId id, PSOpcode opcode, PSTask ta
{
if (provider.IsEnabled(PSLevel.Verbose, keyword))
{
string payLoadData = BitConverter.ToString(fragmentData.blob, fragmentData.offset, fragmentData.length);
payLoadData = string.Create(CultureInfo.InvariantCulture, $"0x{payLoadData.Replace("-", string.Empty)}");
string payLoadData = Convert.ToHexString(fragmentData.blob, fragmentData.offset, fragmentData.length);
payLoadData = string.Create(CultureInfo.InvariantCulture, $"0x{payLoadData}");

provider.WriteEvent(id, PSChannel.Analytic, opcode, PSLevel.Verbose, task, keyword,
objectId, fragmentId, isStartFragment, isEndFragment, fragmentLength,
Expand Down
2 changes: 1 addition & 1 deletion src/TypeCatalogGen/TypeCatalogGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private static string GetAssemblyStrongName(MetadataReader metadataReader)
}

// Convert bytes to hex format strings in lower case.
string publicKeyTokenString = BitConverter.ToString(publicKeyTokenBytes).Replace("-", string.Empty).ToLowerInvariant();
string publicKeyTokenString = Convert.ToHexString(publicKeyTokenBytes).ToLowerInvariant();
string strongAssemblyName = string.Create(CultureInfo.InvariantCulture, $"{asmName}, Version={asmVersion}, Culture={asmCulture}, PublicKeyToken={publicKeyTokenString}");

return strongAssemblyName;
Expand Down