Hola amigos. Al ver el manual de PHP descargué la librería compatible a la versión que dispongo (5.3.28) para el hashing pero tiene errores. Solo son 2 archivos.
version_test.php: "Hay un error de sintaxis en la línea 5. Es posible que las sugerencias para el código no funcionen hasta que resuelva este error".
Código PHP:
Ver original<?php
require "lib/password.php";
echo "Test for functionality of compat library: " . (PasswordCompat\binary\check() ? "Pass" : "Fail");
echo "\n";
?>
password.php: "Hay un error de sintaxis en la línea 10. Es posible que las sugerencias para el código no funcionen hasta que resuelva este error".
Código PHP:
Ver original<?php
/**
* A Compatibility library with PHP 5.5's simplified password hashing API.
*
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @copyright 2012 The Authors
*/
namespace {
/**
* PHPUnit Process isolation caches constants, but not function declarations.
* So we need to check if the constants are defined separately from
* the functions to enable supporting process isolation in userland
* code.
*/
define('PASSWORD_DEFAULT', PASSWORD_BCRYPT
); define('PASSWORD_BCRYPT_DEFAULT_COST', 10); }
/**
* Hash the password using the specified algorithm
*
* @param string $password The password to hash
* @param int $algo The algorithm to use (Defined by PASSWORD_* constants)
* @param array $options The options for the algorithm to use
*
* @return string|false The hashed password, or false on error.
*/
function password_hash
($password, $algo, array $options = array()) { trigger_error("Crypt must be loaded for password_hash to function", E_USER_WARNING); return null;
}
$password = (string) $password;
}
trigger_error("password_hash(): Password must be a string", E_USER_WARNING); return null;
}
trigger_error("password_hash() expects parameter 2 to be long, " . gettype($algo) . " given", E_USER_WARNING); return null;
}
$resultLength = 0;
switch ($algo) {
case PASSWORD_BCRYPT:
$cost = PASSWORD_BCRYPT_DEFAULT_COST;
if (isset($options['cost'])) { $cost = $options['cost'];
if ($cost < 4 || $cost > 31) {
trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING); return null;
}
}
// The length of salt to generate
$raw_salt_len = 16;
// The length required in the final serialization
$required_salt_len = 22;
$hash_format = sprintf("$2y$%02d$", $cost); // The expected length of the final crypt() output
$resultLength = 60;
break;
default:
trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING); return null;
}
$salt_requires_encoding = false;
if (isset($options['salt'])) { switch (gettype($options['salt'])) { case 'NULL':
case 'boolean':
case 'integer':
case 'double':
case 'string':
$salt = (string) $options['salt'];
break;
case 'object':
$salt = (string) $options['salt'];
break;
}
case 'array':
case 'resource':
default:
trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING); return null;
}
...
¿Qué podrá estar mal?