Skip to content

Instantly share code, notes, and snippets.

@paulohenriquesn
Last active February 14, 2018 21:27
Show Gist options
  • Save paulohenriquesn/4c3348056e6153d5afe0bf822c487d42 to your computer and use it in GitHub Desktop.
Save paulohenriquesn/4c3348056e6153d5afe0bf822c487d42 to your computer and use it in GitHub Desktop.
byte[] arraylegal = new byte[128];
void StringToByteArray(string value){
int pointer = 0;
byte[] byteToSendtoArray;
string[] splitSpace = value.Split(' ');
string localMemory = String.Empty;
for (int i = 0; i < splitSpace.Length; i++)
{
localMemory = splitSpace[i];
splitSpace[i] = "0x" + localMemory;
byteToSendtoArray = Encoding.ASCII.GetBytes(splitSpace[i]);
for(int a = 0; a < byteToSendtoArray.Length; a++)
{
arraylegal[pointer] = byteToSendtoArray[a];
pointer += 1;
}
Console.WriteLine(splitSpace[i]);
pointer += 1;
localMemory = String.Empty;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment