encryption - Is the raw output returned by PHP's hashing functions the same as pack('H*')?

Solution:
If you want to have raw binary result, you should go withhash_pbkdf2
with$raw_output = true
. It will generate the bytes that you want without any encoding.
hash_pbkdf2
internally usesbin2hex
to then encode the binary string into hex. This is an additional operation. When you then usepack
to decode the hex into the binary string, you have yet another unnecessary operation.
Using hex output and decoding it back to binary does not improve your security. If anything, it might decrease it, because password hackers might not use these unnecessary steps.
If you're concerned whetherbin2hex
actually reversespack("H*")
, you should usehex2bin
as those are companion functions that are probably reversing each other.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: a non well formed numeric value encountered
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.