Hi!
I've made little code to convert string into hex string...
Public ReadOnly Property ToHexString(ByVal text As String) As String
Get
Dim arrBytes As Integer() = CharsToBytes(text)
Dim sb As StringBuilder = New StringBuilder
For i As Integer = 0 To arrBytes.Length - 1
'// If it's a single digit, append a zero in front of it.
If (Hex(arrBytes(i)).Length = 1) Then
sb.Append("0" + Hex(arrBytes(i)))
Else
sb.Append(Hex(arrBytes(i)))
End If
Next
Return sb.ToString()
End Get
End Property
Private Function CharsToBytes(ByVal text As String) As Integer()
Dim c As Char() = text.ToCharArray()
Dim arrBytes As Integer()
ReDim arrBytes(c.Length() - 1)
For i As Integer = 0 To c.Length() - 1
arrBytes(i) = System.Convert.ToByte(c(i))
Next
Return arrBytes
End Function
.... and it's working fine. For example my name "MIKA" will be "4D494B41"
as hex string, but I don't find out how to do this opposite way? I mean
how to get "MIKA" of "4D494B41" hex string.
Other question: It's possible to change when using VB like...
Asc(c(i)) -> System.Convert.ToByte(c(i))
.... is there also same kind of way for Hex()-function?
--
Thanks in advance!
Mika