HEX2BIN(3) 1 HEX2BIN(3)hex2bin - Decodes a hexadecimally encoded binary stringSYNOPSIS
string hex2bin (string $data)
DESCRIPTION
Decodes a hexadecimally encoded binary string.
Caution
This function does NOT convert a hexadecimal number to a binary number. This can be done using the base_convert(3) function.
PARAMETERS
o $data
- Hexadecimal representation of data.
RETURN VALUES
Returns the binary representation of the given data or FALSE on failure.
ERRORS /EXCEPTIONS
If the hexadecimal input string is of odd length or invalid hexadecimal string an E_WARNING level error is thrown.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.5.1 | |
| | |
| | A warning is thrown if the input string is |
| | invalid hexadecimal string. |
| | |
| 5.4.1 | |
| | |
| | A warning is thrown if the input string is of |
| | odd length. In PHP 5.4.0 the string was silently |
| | accepted, but the last byte was truncated. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
hex2bin(3) example
<?php
$hex = hex2bin("6578616d706c65206865782064617461");
var_dump($hex);
?>
The above example will output something similar to:
string(16) "example hex data"
SEE ALSO bin2hex(3), unpack(3).
PHP Documentation Group HEX2BIN(3)
Check Out this Related Man Page
DECHEX(3) 1 DECHEX(3)dechex - Decimal to hexadecimalSYNOPSIS
string dechex (int $number)
DESCRIPTION
Returns a string containing a hexadecimal representation of the given unsigned $number argument.
The largest number that can be converted is PHP_INT_MAX
* 2 + 1 (or -1): on 32-bit platforms, this will be 4294967295 in decimal, which results in dechex(3) returning ffffffff.
PARAMETERS
o $number
- The decimal value to convert. As PHP's integer type is signed, but dechex(3) deals with unsigned integers, negative integers
will be treated as though they were unsigned.
RETURN VALUES
Hexadecimal string representation of $number.
EXAMPLES
Example #1
dechex(3) example
<?php
echo dechex(10) . "
";
echo dechex(47);
?>
The above example will output:
a
2f
Example #2
dechex(3) example with large integers
<?php
// The output below assumes a 32-bit platform.
// Note that the output is the same for all values.
echo dechex(-1)."
";
echo dechex(PHP_INT_MAX * 2 + 1)."
";
echo dechex(pow(2, 32) - 1)."
";
?>
The above example will output:
ffffffff
ffffffff
ffffffff
SEE ALSO hexdec(3), decbin(3), decoct(3), base_convert(3).
PHP Documentation Group DECHEX(3)
not much familiar with binary and hex calculation in script programming....
explaination:
binary format control the parameter turned on or off in the program stored in hex mode, the question is:
how to change 39e to 19e using the binary calculation(although i don't know the command for... (2 Replies)
Hi ,
i'm using special binary file (lotus notes) and modifying an hexadecimal address range with windows hex editor and it works fine !
The file is an AIX one and i'm forced to transfert (ftp) it before modifying it and re-transfert !
NOW i would do this directly under AIX !
I can... (4 Replies)
Dear friends,
I have hexadecimal data like this.
now i want to read each letter and convert to decimal format.
for example.:
from the below data first i have to read hex data 0 and convert to 4 bit decimal value ie 0000.
similarly second letter 8 decimal value is 1000.
like this.... (6 Replies)
Goodmorning,
I have a hex encoded file that needs to be parsed to remove some bytes and write the remaining ones to a new file. Here is the top of the file as shown by a hex editor:
http://www.wallpaperdepot.com/images/unix/TopofFile.gif
The first parse exercise is to remove bytes 0-87... (6 Replies)
Hello guys,
i want to convert a text file to hex and have written this code :
int main(int argc, char **argv)
{
ifstream file;
string fileName = "CODEZ";
file.open(fileName.c_str()); // oeffen im Text-Modus
if(file)
{... (5 Replies)
Friends, I am looking for a small script which generates HEX sequence. Input to the script is starting hex number - Group ID and number of members a group should have and total groups.
e.g: Here we are generating 2 groups with 4 Members each starting with hex 036A.
Output:
Group ID 036A,... (5 Replies)
TO THE ALMIGHTY FORUM ,
though i have already posted the same question on hex to binary thread , i am posting here also for other beginners who may benefit from this thread...
I have a 32 bit binary containing a series of 1' and 0's , and i am stuck... (2 Replies)
Folks,
can anyone help with a script to convert hex to binary digits, and break the 32 bit binary into packs of 4 and send them to 8 different variables.Any help is sincerely appreciated.
Thanks
venu
Its in korn shell...... (24 Replies)
Hi All
I want to take a Hexadecimal number as input and i want to find lenth of the input and pass it to char s ( char s ). I have a program to convert hexadecial to binary but it is taking limited input but i want to return binary number based on input. How? (1 Reply)
I have a binary (hex) file I need to parse to get some data which are encoded this way:
.* b4 . . . 01 12 .* af .* 83 L1 x1 x2 xL 84 L2 y1 y2 yL
By another words there is a stream of hexadecimal bytes (in my example separated by space for better readability). I need to get value stored in... (3 Replies)
Hi Guys,
Is it possible to convert the hexadecimal to Binary by unix command.....I could not figure out....
If I need to convert AF6D to binary...what could be the way to do?
Thanks in advance!!
---------- Post updated at 02:57 AM ---------- Previous update was at 02:42 AM ----------
I... (6 Replies)
Hello to all,
I have this sed script that replaces hex strins within a binary file.
As you can see, I want to replace all bytes 4X with 2X (where X could take values 0 to F).
sed -e 's/\x40/\x20/g' -e 's/\x41/\x21/g' -e 's/\x42/\x22/g' -e 's/\x43/\x23/g' -e 's/\x44/\x24/g' -e... (7 Replies)