Jump to content

How Do You Convert Rehular Text To Hex?


Recommended Posts

Uh.... Hex() ? :)

AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
Share on other sites

how to you convert regular text like this to hex??

is hex the 0011001010.. thats what i want to convert :)

i tried html based and they get the % for some reason.

%61%75%74%6F%69%74%20%72%6F%63%6B%73

umm no thats binary (i think unless just a bad example of hex)

dunno if theres a function to convert normal text to binary

it goes by ASCII character values then turns then into binarys by finding its base 2 equivelent

Edited by Paulie
Link to comment
Share on other sites

If it is binary you want and not hex, use BinaryString()

AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
Share on other sites

You need beta

AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
Share on other sites

  • Moderators

Hmm, I don't understand Binary at all either, but this was the only thing that gave me a correct result:

$var = String('autoit rocks' & Chr(0))
$g = BinaryString($var)
If $var = String($g) Then MsgBox(0, 'Test1', 'equals')
MsgBox(0, 'Test2', $var)
MsgBox(0, 'Test3', $g)

Edit:

And if the above is right, this should work as well:

$Test1 = _BinaryConvert('a')
MsgBox(64, 'Conversion', $Test1)
MsgBox(64, 'Conversion', _BinaryConvert($Test1))

Func _BinaryConvert($vs_Value)
    If Not IsBinaryString($vs_Value) Then Return String($vs_Value & Chr(0))
    If IsBinaryString($vs_Value) Then Return BinaryString($vs_Value)
    SetError(1); $i_ConvertTo Not a 1 or 0
    Return 0
EndFunc

Edit2:

I don't think mine is right though, I'm not getting the same values as the help file is getting :)

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

cool.. thanks smoke

#include <string.au3>

$Hex = "4175746F697400526F636B73"
$String = _HexToString($Hex)
MsgBox(0, "Hex", "Original Hex: " & $Hex & @LF & " String: " & $String)

$String = "Autoit Rocks"
$Hex = _StringToHex($String)
MsgBox(0, "Hex", "Original String:" & $String & @LF & " Hex: " & $Hex)


MsgBox(64, 'Binary', _BinaryConvert("Original Hex: " & 'Autoit Rocks'))
MsgBox(64, 'Binary', _BinaryConvert("Original String:" & 'Autoit Rocks', 0))


Func _BinaryConvert($vs_Value, $i_ConvertTo = 1)
    If $i_ConvertTo Then Return String($vs_Value & Chr(0))
    If $i_ConvertTo = 0 Then Return BinaryString($vs_Value)
    SetError(1); $i_ConvertTo Not a 1 or 0
    Return 0
EndFunc

with this code below i get same kind of string with hex and binary, expcet binary has the 0x at the begin.. i assume this one is wrong..

#include <string.au3>

$a= "Autoit Rocks"& chr(0)
$var = BinaryString($a)
$str = String($var)
msgbox(0, "Binary","Binary: " & $str)


$Hex = "4175746F697400526F636B73"
$String = _HexToString($Hex)
MsgBox(0, "Hex", "Original Hex: " & $Hex & @LF & " String: " & $String)


$String = "Autoit Rocks"
$Hex = _StringToHex($String)
MsgBox(0, "Hex", "Original String:" & $String & @LF & " Hex: " & $Hex)
Link to comment
Share on other sites

  • Moderators

I still don't think mine is right :) :

$Test1 = _BinaryConvert('Hello' & @CRLF & 'This is the ' & 1 & 'st test')
MsgBox(64, 'Conversion', $Test1)
MsgBox(64, 'Conversion', _BinaryConvert($Test1))

Func _BinaryConvert($vs_Value)
;#cs
    If IsInt($vs_Value) Then 
        $vs_Value = BinaryString($vs_Value)
        Return String($vs_Value)
    EndIf
;#ce
    If Not IsBinaryString($vs_Value) Then
        $vs_Value = BinaryString($vs_Value)
        Return String($vs_Value & Chr(0))
    EndIf
    If IsBinaryString($vs_Value) Then Return BinaryString($vs_Value)
    SetError(1); $i_ConvertTo Not a 1 or 0
    Return 0
EndFunc
When you put a Int in it fails because of the '& Chr(0)', So I played with IsInt() and it returns what it should to make it binary but does not convert a value. I was reading a help file says it Does Not Return '10' but still can't make heads or tails of it.

Edit:

Took $i_Convert out, used IsBinaryString() instead.

Maybe someone else can shed some enlightenment to us :(.

Edit2:

Yeh, it does convet to hex the same except the 0x and 00 on the end lol:

#include <string.au3>
$Test1 = _BinaryConvert('Hello' & @CRLF & 'This is the ' & 1 & 'st test')
$Test2 = '0x' & _StringToHex('Hello' & @CRLF & 'This is the ' & 1 & 'st test')
ClipPut($Test1 & @CRLF & $Test2)
MsgBox(0, 'Hex', $Test2)
MsgBox(64, 'Conversion', $Test1)
MsgBox(64, 'Conversion', _BinaryConvert($Test1))
If StringTrimRight($Test1, 2) = $Test2 Then MsgBox(64, 'Info', $Test1 & @CR & $Test2)

Func _BinaryConvert($vs_Value)
;#cs
    If IsInt($vs_Value) Then 
        $vs_Value = BinaryString($vs_Value)
        Return String($vs_Value)
    EndIf
;#ce
    If Not IsBinaryString($vs_Value) Then
        $vs_Value = BinaryString($vs_Value)
        Return String($vs_Value & Chr(0))
    EndIf
    If IsBinaryString($vs_Value) Then Return BinaryString($vs_Value)
    SetError(1); $i_ConvertTo Not a 1 or 0
    Return 0
EndFunc
So I can't imagine that is right what I did. Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...