//-----------------------------------------------------------------------
//
// Copyright (c) ParanoidMike. All rights reserved.
//
//-----------------------------------------------------------------------
namespace ParanoidMike
{
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using Microsoft.Win32;
///
/// Reusable functions for many uses.
///
public static class Utility
{
///
/// Takes in any string and convert it into a Byte array, suitable for e.g. insertion into a REG_BINARY Registry value.
///
///
/// String value to be converted to a Byte array.
///
///
/// Byte array, converted from the input String value.
///
public static byte[] ConvertStringToByteArray(string inputString)
{
byte[] outputByteArray;
string[] hexCodesFromString = inputString.Split(',');
int upperBound = hexCodesFromString.GetUpperBound(0);
outputByteArray = new byte[upperBound]; // doing this to resolve uninitialized variable error that appeared below
for (int i = 0; i < upperBound; i++)
{
outputByteArray[i] = Convert.ToByte(hexCodesFromString[i], 16);
}
return outputByteArray;
}
}
}