Jump to content

Replicate PHP pack('H*' ... in autoit


Kyan
 Share

Go to solution Solved by Luigi,

Recommended Posts

Hey

I don't know PHP, was trying to get the same output of PHP pack function, already read http://php.net/manual/en/function.pack.php but didn't found a proper translation for "high nible"

I tried with StringFormat('%X',"6D2222E8B845C7B2199357B5FAF9B2C57C8FDAB4") but isn't the same thing

I found this page http://perplexed.co.uk/960_php_pack_function.htm but I don't know how to replicate it in autoit

Can someone lend a hand and point me in the right direction?

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Link to comment
Share on other sites

@Luigi, if is a non pair hex string like 7chrs long, how shoud I pad it?

'0'&$7chrStr or $7chrStr&'0'?

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Link to comment
Share on other sites

it should be padded from the left. tested the output using this site http://writecodeonline.com/php/ (use bin2hex() on php and Binary() to check if the pack output matches)

Edited by Kyan

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Link to comment
Share on other sites

  • Moderators

BTW, packH looks nothing more than:

Func _packH($sInput)
    Return ((StringLeft($sInput, 2) = "0x") ? _
        BinaryToString($sInput):BinaryToString("0x" & $sInput))
EndFunc

To me... or am I missing something?

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