byte[] ba = Encoding.Default.GetBytes("sample"); var hexString = BitConverter.ToString(ba); hexString = hexString.Replace("-", "");