Skip to content
This repository has been archived by the owner on May 11, 2019. It is now read-only.

Commit

Permalink
Added further documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed May 1, 2013
1 parent 47d5e43 commit bebd109
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@ to the native function when it is available.

See the [PHP manual entry](http://php.net/hash_pbkdf2).

**IMPORTANT:** Note that although the documentation does not specify, the
`$length` parameter is *currently* implemented as a **string length**, not a
byte length. This means that when `$raw_output` is false, `$length` needs to be
doubled to produce a hash containing the same amount of data (because hex
encoding doubles the number of bytes in the result string). It is unknown
whether this will change once PHP 5.5 is out of beta.
## Behaviour of length parameter

Although the documentation does not specify, the `$length` parameter is
*currently* implemented as a **string length**, not a byte length. This means
that when `$raw_output` is false, `$length` needs to be doubled to produce a
hash containing the same amount of data (because hex encoding doubles the number
of bytes in the result string).

When `$length` is set to 0 (i.e. use the default length), the native
implementation will halve the length of data returned if `$raw_output` is false.
This is almost certainly a bug, and the issue has been raised
[here](https://bugs.php.net/bug.php?id=64745).

It is unknown whether these behaviours will change once PHP 5.5 is out of beta.

## Acknowledgements

Expand Down

0 comments on commit bebd109

Please sign in to comment.