mirror of
https://github.com/aphrody-labs/NuGet.Client.git
synced 2026-10-14 13:29:05 +00:00
34 lines
898 B
C#
34 lines
898 B
C#
// Copyright (c) .NET Foundation. All rights reserved.
|
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
|
|
namespace NuGet.Shared
|
|
{
|
|
internal static class EncodingUtility
|
|
{
|
|
internal static string ToHex(byte[] bytes, int length)
|
|
{
|
|
char[] c = new char[length * 2];
|
|
|
|
for (int index = 0, outIndex = 0; index < length; index++)
|
|
{
|
|
c[outIndex++] = ToHexChar(bytes[index] >> 4);
|
|
c[outIndex++] = ToHexChar(bytes[index] & 0x0f);
|
|
}
|
|
|
|
return new string(c);
|
|
}
|
|
|
|
private static char ToHexChar(int input)
|
|
{
|
|
if (input > 9)
|
|
{
|
|
return (char)(input + 0x57);
|
|
}
|
|
else
|
|
{
|
|
return (char)(input + 0x30);
|
|
}
|
|
}
|
|
}
|
|
}
|