alexandernst / yii2-scrypt
Scrypt key derivation function for Yii2
Installs: 77
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2025-02-01 19:51:04 UTC
README
Scrypt key derivation function for Yii2
To use it just require this extension in your composer.json file:
"alexandernst/yii2-scrypt": "0.0.4",
And then add it to your components configuration in Yii2:
'components' => [ 'Scrypt' => [ 'class' => 'alexandernst\Scrypt\Scrypt' ], ]
To derivate a key, use the following method:
/** * Scrypt algorithm * * @param string $password * @param string $salt * @param int $n CPU/Memory cost parameter, must be larger than 1, a power of 2 and less than 2^(128 * r / 8) * @param int $r Block size * @param int $p Parallelization parameter, a positive integer less than or equal to ((2^32-1) * hLen) / MFLen where hLen is 32 and MFlen is 128 * r * @param int $length Length of the output key * @throws Exception * @return string */ echo bin2hex(\Yii::$app->Scrypt->calc("plain password", "salt", 8, 8, 16, 32));
This class passes all the tests specified in the documentation.