Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug #61660 bin2hex(hex2bin($data)) != $data #51

Closed
wants to merge 1 commit into from
Closed

Bug #61660 bin2hex(hex2bin($data)) != $data #51

wants to merge 1 commit into from

Conversation

srgoogleguy
Copy link
Contributor

This bug fix now introduces a second optional argument to hex2bin that will comply with BC.
Additionally, the patch prevents an empty string from being accepted (as the existing patch did not).

This bug fix now introduces a second optional argument to hex2bin that will comply with BC
@srgoogleguy
Copy link
Contributor Author

As per our conversation on IRC:

"Just to clarify beforehand, as there is some confusion about this:
hex2bin does not convert a hex number to a binary number. hex2bin converts a hexadecimally encoded binary string into a non-encoded binary string. To emphasize again: hex2bin has (nearly) nothing to do with numbers. It's a way to encode strings (or better to say binary strings, but in PHP all strings are binary). And as every byte of data is encoded using two hexadecimal characters (16 * 16 = 256) the encoded string can't be of odd length. Two hex digits always form a pair."

It's clear that many people agree the documentation on hex2bin is quite confusing in this matter. A note has been made to fix this in the doc. Closing PR...thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant