-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup project and improve error handling
This commit looks bigger than it is. Most of the changes are cosmetic, although the function body has changed to better simulate the error conditions and messages of the built-in function found in PHP >=5.5. Other changes are listed below: - Add LICENSE.md file - Update phpunit development dependency - Update tests to check for proper error handling - Update tests to check for the conditions of PR #1 - Add docblocks compatible with the built-in function - Minor changes to git and travis configurations
- Loading branch information
1 parent
221c967
commit dda9de5
Showing
11 changed files
with
308 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/tests export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.travis.yml export-ignore | ||
/phpunit.xml.dist export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
build/ | ||
nbproject/ | ||
vendor/ | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Ryan Chouinard <rchouinard@gmail.com> | ||
|
||
> Permission is hereby granted, free of charge, to any person obtaining a copy | ||
> of this software and associated documentation files (the "Software"), to deal | ||
> in the Software without restriction, including without limitation the rights | ||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
> copies of the Software, and to permit persons to whom the Software is | ||
> furnished to do so, subject to the following conditions: | ||
> | ||
> The above copyright notice and this permission notice shall be included in | ||
> all copies or substantial portions of the Software. | ||
> | ||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
> THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="vendor/autoload.php" verbose="true" colors="true"> | ||
<testsuites> | ||
<testsuite name="hash_pbkdf2-compat Test Suite"> | ||
<directory>tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src/</directory> | ||
</whitelist> | ||
</filter> | ||
<logging> | ||
<log type="tap" target="build/report.tap" /> | ||
<log type="junit" target="build/report.junit.xml" /> | ||
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true" /> | ||
<log type="coverage-text" target="build/coverage.txt" /> | ||
<log type="coverage-clover" target="build/logs/clover.xml" /> | ||
</logging> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,47 @@ | ||
<?php | ||
/** | ||
* This file is part of Rych\hash_pbkdf2-compat | ||
* | ||
* (c) Ryan Chouinard <rchouinard@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
// @codeCoverageIgnoreStart | ||
require __DIR__ . '/hash_pbkdf2.php'; | ||
|
||
if (!function_exists('\hash_pbkdf2')) { | ||
function hash_pbkdf2($algo, $password, $salt, $iterations, $length = 0, $raw_output = false) | ||
{ | ||
return \Rych\hash_pbkdf2($algo, $password, $salt, $iterations, $length, $raw_output); | ||
} | ||
|
||
/** | ||
* @param string $algo Name of selected hashing algorithm (i.e. md5, | ||
* sha256, haval160,4, etc..) See hash_algos() for | ||
* a list of supported algorithms. | ||
* @param string $password The password to use for the derivation. | ||
* @param string $salt The salt to use for the derivation. This value | ||
* should be generated randomly. | ||
* @param integer $iterations The number of internal iterations to perform for | ||
* the derivation. | ||
* @param integer $length The length of the output string. If raw_output | ||
* is TRUE this corresponds to the byte-length of | ||
* the derived key, if raw_output is FALSE this | ||
* corresponds to twice the byte-length of the | ||
* derived key (as every byte of the key is | ||
* returned as two hexits). | ||
* | ||
* If 0 is passed, the entire output of the | ||
* supplied algorithm is used. | ||
* @param boolean $raw_output When set to TRUE, outputs raw binary data. | ||
* FALSE outputs lowercase hexits. | ||
* @return string Returns a string containing the derived key as | ||
* lowercase hexits unless raw_output is set to | ||
* TRUE in which case the raw binary representation | ||
* of the derived key is returned. | ||
*/ | ||
function hash_pbkdf2($algo = null, $password = null, $salt = null, $iterations = null, $length = 0, $raw_output = false) | ||
{ | ||
return \Rych\hash_pbkdf2($algo, $password, $salt, $iterations, $length, $raw_output); | ||
} | ||
|
||
} | ||
// @codeCoverageIgnoreEnd |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.