Class to add scrypt hashing to the Phalcon framework. Requires scrypt extension.
This class is an extension to the built-in Phalcon\Security class that add functions to generate scrypt hashes that are compatible with the wg/scrypt Java implementation.
Install composer in a common location or in your project:
bash
curl -s http://getcomposer.org/installer | php
Create the composer.json file as follows:
json
{
"require": {
"moderndeveloperllc/phalconscrypt" : "1.0.*"
}
}
Run the composer installer:
bash
php composer.phar install
You will need to overwrite the existing Security service with the new class. You will have access to all the Phalcon\Security
functions as the PhalconScrypt
class extends that class.
``` <?php use ModDev\PhalconScrypt\PhalconScrypt;
$di->set( 'security', function () { return new PhalconScrypt(); }, true ); ```
Library Installed Manually
<?php
//Make sure to register namespace
$loader->registerNamespaces(array(
//Other namespaces
'ModDev\PhalconScrypt' => $path->to->library . '/src/ModDev/PhalconScrypt'
));
If you install the library manually, be sure to load the library in your autoloader. The easiest to do is in a registerNamespaces()
function. There is only one class at the moment, but that could change in the future.
Library Installed via Composer ``` <?php // Your existing loader config... // ...
requireonce _DIR__ . '/../../vendor/autoload.php'; ```
``` <?php
$hashedPassword = $this->security->scryptHash('myReallyGreatPassword'); ```
``` <?php
$passwordWorksBoolean = $this->security->scryptCheckHash($cleartextPassword, $hashedPassword); ```
``` <?php
$passwordhashType = $this->security->getHashType($hashedPassword); ```