/*
* Copyright (c) United Binary LLC. All rights reserved.
*
* This code is licensed under the MIT License
*
* SEE: http://harnessit.codeplex.com/license
*
*/
#region using ...
using System;
using System.Text;
#endregion
namespace UnitedBinary.Core.Utility.Text
{
///
public sealed class Format
{
private Format() {}
///
public static byte[] HexStringToBytes(string source)
{
if (source.Length % 2 != 0)
{
throw new ArgumentException("Argument must be divisible by two.", "source");
}
byte[] bytes = new byte[source.Length/2];
for (int i=0; i < bytes.Length; i++)
{
bytes[i] = Convert.ToByte(source.Substring(i * 2, 2), 16);
}
return bytes;
}
}
}