28
Mar
09

[VB.Net] String to Hex Conversion

Migrating old code snippits over to the new blog.

Function StringToHex(ByVal text As String) As String
    Dim hex As String
    For i As Integer = 0 To text.Length - 1
        hex &= Asc(text.Substring(i, 1)).ToString("x").ToUpper
    Next
    Return hex
End Function

Usage:

Debug.WriteLine(StringToHex("sim0n"))

Would Output:
73696D306E

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: