How to convert hexadecimal string to byte string in Perl?

My source code is in Python , but I need to convert it to Perl for some libraries that I don't have on my uninstall in Python.

In Python, I would do the following:

packet=binascii.unhexlify('F0000000F6905C452001A8C0000000000160994E810FB54E0100DB0000000000000') 

and

This will create a string containing a binary representation:

 0xF0 0x00 0x00 0x00 0xF6 0x90 0x5C 0x45 etc... 

Now that my string is an array of bytes, I can send it as a payload for my package. How do I do this perl?

+7
source share
1 answer

You can use pack .

Example:

 $ perl -e 'print pack("H*", "303132616263"), "\n";' 012abc 

Check out the package tutorial .

+7
source

All Articles