Sign in to follow this  
Followers 0
ReaImDown

Help converting strings to hex / binary and back

5 posts in this topic

I am trying to take my name (Randy) ...convert it...but I cant convert it back...tried everything I could think of...

Thank you for your help -.-'

#include<String.au3>
MsgBox(0,"",_StringToHex(Binary("Randy")))

msgbox(0,"",_hexToString("307835323631364536343739")); Randy

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites



I am trying to take my name (Randy) ...convert it...but I cant convert it back...tried everything I could think of...

Thank you for your help -.-'

#include<String.au3>
MsgBox(0,"",_StringToHex(Binary("Randy")))

msgbox(0,"",_hexToString("307835323631364536343739")); Randy

$sStr = "Randy"
$sHex = __StringToHex($sStr)
MsgBox(0, "", $sHex)
$sConvert = __HexToString($sHex)
MsgBox(0, "", $sConvert)

Func __StringToHex($sString)
    Return Hex(StringToBinary($sString))
EndFunc

Func __HexToString($sString)
    If StringLeft($sString, 2) <> "0x" Then $sString = "0x" & $sString
    Return BinaryToString($sString)
EndFunc

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.

Share this post


Link to post
Share on other sites

$sStr = "Randy"
$sHex = __StringToHex($sStr)
MsgBox(0, "", $sHex)
$sConvert = __HexToString($sHex)
MsgBox(0, "", $sConvert)

Func __StringToHex($sString)
    Return Hex(StringToBinary($sString))
EndFunc

Func __HexToString($sString)
    If StringLeft($sString, 2) <> "0x" Then $sString = "0x" & $sString
    Return BinaryToString($sString)
EndFunc
I wanted it to be hard for someone to reverse my code, I am really going to use it for a password....so I wanted it converted to hex, then binary....then backwards back to a string.

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites

I wanted it to be hard for someone to reverse my code, I am really going to use it for a password....so I wanted it converted to hex, then binary....then backwards back to a string.

Why not just use actual encryption with _StringEncrypt() or the binary RC4() by SkinnyWhiteGuy (or DES or several other he posted), or __StringEncrypt() by me?

Of course, if you are going to make it reversible (store the key with the encrypted item), then it will still be hackable...

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I wanted it to be hard for someone to reverse my code, I am really going to use it for a password....so I wanted it converted to hex, then binary....then backwards back to a string.

Well, even using Binary, you're essentially converting it to hex twice there.. and you're only trying to convert it back once.

Using my string to hex methods because they are much much faster:

MsgBox(0,"",__StringToHex(Binary("Randy")))

msgbox(0,"",__HexToString(__HexToString("307835323631364536343739"))); Randy

Func __StringToHex($sString)
    Return Hex(StringToBinary($sString))
EndFunc

Func __HexToString($sString)
    If StringLeft($sString, 2) <> "0x" Then $sString = "0x" & $sString
    Return BinaryToString($sString)
EndFunc
But you should see your mistake in the 2nd message box.

Also take note on what PSalty is suggesting.


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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0