Kyan

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

7 posts in this topic

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

pack's php have many options... in the past, I need a pack option too, after many try, I build the function above, I need the option H, becouse packH.

but, have the another pack's options...


Visit my repository

Share this post


Link to post
Share on other sites

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?

1 person likes this

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

Damn, there's such inline operators? wow


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

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