|
// 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);
}
}
}
}
|