*/
protected static function strlen (string $str): int
{
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('[%s:%d]: str=%s - CALLED!', __METHOD__, __LINE__, $str));
static $isShadowed = null;
if ($isShadowed === null) {
ini_get('mbstring.func_overload') & 2;
}
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('[%s:%d]: isShadowed=%d', __METHOD__, __LINE__, (int) $isShadowed));
if ($isShadowed) {
return mb_strlen($str, '8bit');
} else {
*
* @return string The salt
*/
- public static function generateScryptSalt (int $length = 8): str
+ public static function generateScryptSalt (int $length = 8): string
{
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('[%s:%d]: length=%d - CALLED!', __METHOD__, __LINE__, $length));
+
$buffer = '';
$buffer_valid = false;
if (function_exists('mcrypt_create_iv') && !defined('PHALANGER')) {
}
}
}
+
$salt = str_replace(array('+', '$'), array('.', ''), base64_encode($buffer));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('[%s:%d]: salt=%s - EXIT!', __METHOD__, __LINE__, $salt));
return $salt;
}
*/
public static function hashScrypt (string $password, string $salt = '', int $N = 16384, int $r = 8, int $p = 1): string
{
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('[%s:%d]: password=%s,salt=%s,N=%d,r=%d,p=%d - CALLED!', __METHOD__, __LINE__, $password, $salt, $N, $r, $p));
if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) {
// Feature has been disabled
throw new InvalidArgumentException('Feature "scrypt" disabled.');
throw new InvalidArgumentException('Parameter r is too large');
}
- if ($salt === false) {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('[%s:%d]: salt=%s - BEFORE!', __METHOD__, __LINE__, $salt))
+ if ($salt === '') {
$salt = self::generateScryptSalt();
} else {
// Remove dollar signs from the salt, as we use that as a separator.
$salt = str_replace(array('+', '$'), array('.', ''), base64_encode($salt));
}
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('[%s:%d]: salt=%s - AFTER!', __METHOD__, __LINE__, $salt))
$hash = scrypt($password, $salt, $N, $r, $p, self::$_keyLength);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('[%s:%d]: hash=%s', __METHOD__, __LINE__, $hash))
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('[%s:%d]: %d$%d$%d$%s$%s - CALLED!', __METHOD__, __LINE__, $N, $r, $p, $salt, $hash));
return $N . '$' . $r . '$' . $p . '$' . $salt . '$' . $hash;
}