This a rather simple question for all you studs out there! Please help me
with this. I have a string = "Please help me", and I want to convert this
into it's hex equivalent. How do I do it, I have trying for a couple hours
and can't seem to get my head straight arount this whole conversion things.
TIA, LCD 6 43134
Not sure exactly what you want to do but check out the Hex Function, Convert
Class, and ToCharArray string method. One or all of these in combination
should get you what you want.
--
Dennis in Houston
"LCD" wrote: This a rather simple question for all you studs out there! Please help me with this. I have a string = "Please help me", and I want to convert this into it's hex equivalent. How do I do it, I have trying for a couple hours and can't seem to get my head straight arount this whole conversion things.
TIA, LCD
Okay I want to doing something similar to this. In python, there is a
function called "binascii".
So if I type:
### binascii.hexlify('hello world')
This is the result I get:
'68656c6c6f20776f726c64'
###
I want to do something similar in VB.NET or C#. Can someone help?
"Dennis" wrote:
Not sure exactly what you want to do but check out the Hex Function, Convert Class, and ToCharArray string method. One or all of these in combination should get you what you want. -- Dennis in Houston
"LCD" wrote:
This a rather simple question for all you studs out there! Please help me with this. I have a string = "Please help me", and I want to convert this into it's hex equivalent. How do I do it, I have trying for a couple hours and can't seem to get my head straight arount this whole conversion things.
TIA, LCD
Dim str As String = "hello world"
Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(str)
"LCD" wrote: Okay I want to doing something similar to this. In python, there is a function called "binascii".
So if I type: ### binascii.hexlify('hello world')
This is the result I get:
'68656c6c6f20776f726c64' ###
I want to do something similar in VB.NET or C#. Can someone help?
"Dennis" wrote:
Not sure exactly what you want to do but check out the Hex Function, Convert Class, and ToCharArray string method. One or all of these in combination should get you what you want. -- Dennis in Houston
"LCD" wrote:
This a rather simple question for all you studs out there! Please help me with this. I have a string = "Please help me", and I want to convert this into it's hex equivalent. How do I do it, I have trying for a couple hours and can't seem to get my head straight arount this whole conversion things.
TIA, LCD
I just realized you are probably asking for the ascii values of each
character of a string in hex format. This should do it for you:
Dim str As String = "hello world"
Dim byteArray() As Byte
Dim hexNumbers As System.Text.StringBuilder = New System.Text.StringBuilder
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(str)
For i As Integer = 0 To byteArray.Length - 1
hexNumbers.Append(byteArray(i).ToString("x"))
Next
MessageBox.Show(hexNumbers.ToString())
The output should be:
68656c6c6f20776f726c64
"rmacias" wrote: Dim str As String = "hello world" Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(str)
"LCD" wrote:
Okay I want to doing something similar to this. In python, there is a function called "binascii".
So if I type: ###>> binascii.hexlify('hello world')
This is the result I get:
'68656c6c6f20776f726c64' ###
I want to do something similar in VB.NET or C#. Can someone help?
"Dennis" wrote:
Not sure exactly what you want to do but check out the Hex Function, Convert Class, and ToCharArray string method. One or all of these in combination should get you what you want. -- Dennis in Houston
"LCD" wrote:
> This a rather simple question for all you studs out there! Please help me > with this. I have a string = "Please help me", and I want to convert this > into it's hex equivalent. How do I do it, I have trying for a couple hours > and can't seem to get my head straight arount this whole conversion things. > > TIA, LCD
Dude, you are genius!
You made it like POC (piece of cake). Now please explain me this, I didn't
quite catch this part:
hexNumbers.Append(byteArray(i).ToString("x"))
where is this "x" coming from? and why?
TIA, LCD
"rmacias" wrote: I just realized you are probably asking for the ascii values of each character of a string in hex format. This should do it for you:
Dim str As String = "hello world" Dim byteArray() As Byte Dim hexNumbers As System.Text.StringBuilder = New System.Text.StringBuilder
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(str)
For i As Integer = 0 To byteArray.Length - 1 hexNumbers.Append(byteArray(i).ToString("x")) Next
MessageBox.Show(hexNumbers.ToString())
The output should be: 68656c6c6f20776f726c64
"rmacias" wrote:
Dim str As String = "hello world" Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(str)
"LCD" wrote:
Okay I want to doing something similar to this. In python, there is a function called "binascii".
So if I type: ### >>> binascii.hexlify('hello world')
This is the result I get:
'68656c6c6f20776f726c64' ###
I want to do something similar in VB.NET or C#. Can someone help?
"Dennis" wrote:
> Not sure exactly what you want to do but check out the Hex Function, Convert > Class, and ToCharArray string method. One or all of these in combination > should get you what you want. > -- > Dennis in Houston > > > "LCD" wrote: > > > This a rather simple question for all you studs out there! Please help me > > with this. I have a string = "Please help me", and I want to convert this > > into it's hex equivalent. How do I do it, I have trying for a couple hours > > and can't seem to get my head straight arount this whole conversion things. > > > > TIA, LCD
The Byte structure has several overloaded ToString() methods. The one used
below accepts a string representation of a NumberFormatInfo.
"X" or "x" means the format will be hexadecimal
"D" or "d" means the format will be in decimal, etc.
The below links shows possible formats: http://msdn.microsoft.com/library/de...classtopic.asp
"LCD" wrote: Dude, you are genius!
You made it like POC (piece of cake). Now please explain me this, I didn't quite catch this part:
hexNumbers.Append(byteArray(i).ToString("x"))
where is this "x" coming from? and why?
TIA, LCD
"rmacias" wrote:
I just realized you are probably asking for the ascii values of each character of a string in hex format. This should do it for you:
Dim str As String = "hello world" Dim byteArray() As Byte Dim hexNumbers As System.Text.StringBuilder = New System.Text.StringBuilder
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(str)
For i As Integer = 0 To byteArray.Length - 1 hexNumbers.Append(byteArray(i).ToString("x")) Next
MessageBox.Show(hexNumbers.ToString())
The output should be: 68656c6c6f20776f726c64
"rmacias" wrote:
Dim str As String = "hello world" Dim byteArray() As Byte
byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(str)
"LCD" wrote:
> Okay I want to doing something similar to this. In python, there is a > function called "binascii". > > So if I type: > ### > >>> binascii.hexlify('hello world') > > This is the result I get: > > '68656c6c6f20776f726c64' > ### > > I want to do something similar in VB.NET or C#. Can someone help? > > "Dennis" wrote: > > > Not sure exactly what you want to do but check out the Hex Function, Convert > > Class, and ToCharArray string method. One or all of these in combination > > should get you what you want. > > -- > > Dennis in Houston > > > > > > "LCD" wrote: > > > > > This a rather simple question for all you studs out there! Please help me > > > with this. I have a string = "Please help me", and I want to convert this > > > into it's hex equivalent. How do I do it, I have trying for a couple hours > > > and can't seem to get my head straight arount this whole conversion things. > > > > > > TIA, LCD This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Hal Vaughan |
last post by:
If I have a byte and I convert it to string (String sData = new
String(byte bData), then convert it back (byte bData = sData.getBytes()),
will all data be intact, or do Strings have problems with...
|
by: Jonas Prismesen |
last post by:
Hi!
I have string like this:
string expr = "123/(12*3)";
And I want to actually calculate the mathematical
expression in the string. Is there an easy way do it? Or
do I have to extract all...
|
by: Gil |
last post by:
I have a string :
string A = "2";
I need to get it's integer value :
// ??
int val = A ; // ??
|
by: AlexFarokhyans |
last post by:
Hello,
I'm trying to convert String to Char array. I'm getting a string from
user input text box and then I have char firstName.
I need to convert the string that is in the text box to
firstName....
|
by: rainmaker1234 |
last post by:
Its very simple in VC++. In the followeing code I have declared a
String, and a double than I am taking the string and converting it into
Double. getch() at the end is only to pause the screen so...
| |
by: Sandra |
last post by:
I am trying to convert a string into a uniqueidentifier by using the following code
string contrID = Request.Params["oId"
SqlGuid sqlID = SqlGuid.Parse(contrID
I am then putting sqlID into my...
|
by: mdawoodk |
last post by:
i am getting error "input string was not in correct format" when
converting a string decimal into integer value.
code is like this:
string strVal = "";
int nVal = 0;
strVal = "14.9";
nVal...
|
by: SMichal |
last post by:
Hi, how can I parse string "? 20.000" to double ?
|
by: coconet |
last post by:
I have a string like this
mystring = "color1:blue;color2:red";
I am tring to convert this into an IDictionary populated like this:
color1 blue
color2 red
My non-working syntax is
|
by: kronus |
last post by:
I'm receiving an xml file that has a child called modified and it represents a date value in the form of a string -- Nov 14, 2008 -- and in my app, I have items associated with each object and I'm...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |