String to HexCode conversion
//This converts a string into Hex code
private void buttonViewAsHex_Click(object sender, System.EventArgs e)
{
string hex=”";
//Getting the textbox text and converting it to bytes
byte[] bytes = System.Text.ASCIIEncoding.ASCII.GetBytes(this.textBoxText.Text);
// bytes contains the integer values for the character code of each individual character, now you just have to convert from int to hex.
foreach (int i in bytes)
{
hex += ” ” + Convert.ToString(i, 16).ToUpper();
}
//Adding the hexcode to the textbox
this.textBoxHex.Text = hex;
}
