Skip to content

Commit

Permalink
New method HexStringToBytes. Disabled undocumented functions warn
Browse files Browse the repository at this point in the history
  • Loading branch information
grandsilence committed Jul 13, 2018
1 parent b420fd7 commit 6b3d7cf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Leaf.Core/Extensions/String/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@ public static string GetJsonValueEx(this string json, string key, string ending
?? throw new StringBetweenException($"Не найдено значение JSON ключа \"{key}\". Ответ: {json}");
}


/// <summary>
/// Конвертирует HEX строку в оригинальный набор байт
/// </summary>
/// <param name="hexString">Строка сданными в виде HEX</param>
/// <returns>Оригинальный набор байт</returns>
public static byte[] HexStringToBytes(this string hexString)
{
int numberChars = hexString.Length;
var bytes = new byte[numberChars / 2];
for (int i = 0; i < numberChars; i += 2)
bytes[i / 2] = Convert.ToByte(hexString.Substring(i, 2), 16);

return bytes;
}

/// <summary>
/// Возращает тип форматирование числа с разделением тысяч.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions Leaf.Core/Leaf.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<Copyright>© 2018 Developed by Grand Silence — Kelog Studio</Copyright>
<PackageTags>threading,patterns,strings,serialization</PackageTags>
<PackageIconUrl>https://raw.githubusercontent.com/csharp-leaf/Leaf.Core/master/Icons/icon-300.png</PackageIconUrl>
<NoWarn>1591</NoWarn>
</PropertyGroup>

<!-- :: // Generic configurations -->
Expand Down

0 comments on commit 6b3d7cf

Please sign in to comment.