Jump to content

Help converting strings to hex / binary and back


Recommended Posts

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]
Link to comment
Share on other sites

  • Moderators

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.

Link to comment
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]
Link to comment
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
Link to comment
Share on other sites

  • Moderators

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.

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...