Example #1
0
                    $read = strlen($buffer);
                }
                fclose($f);
                if ($read >= $raw_length) {
                    $buffer_valid = true;
                }
            }
        }
        if (!$buffer_valid || strlen($buffer) < $raw_length) {
            $bl = strlen($buffer);
            for ($i = 0; $i < $raw_length; $i++) {
                if ($i < $bl) {
                    $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255));
                } else {
                    $buffer .= chr(mt_rand(0, 255));
                }
            }
        }
        $salt = str_replace('+', '.', base64_encode($buffer));
    }
    $salt = substr($salt, 0, $required_salt_len);
    $hash = $hash_format . $salt;
    $ret = crypt($password, $hash);
    if (!is_string($ret) || strlen($ret) <= 13) {
        return false;
    }
    return $ret;
}
echo __password_hash('[[admin_pass]]', 1, array());
// We do not need this file any more
unlink('update_pass.php');
Example #2
0
<?php

define('PASSWORD_BCRYPT', 1);
define('PASSWORD_DEFAULT', PASSWORD_BCRYPT);
echo __password_hash('[[admin_pass]]', PASSWORD_BCRYPT, '[[_aPwdOptions]]');
/**
 * 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())
{
    global $error;
    if (!function_exists('crypt')) {
        $error[] = "Crypt must be loaded for password_hash to function";
        return null;
    }
    if (!is_string($password)) {
        $error[] = "password_hash(): Password must be a string";
        return null;
    }
    if (!is_int($algo)) {
        $error[] = "password_hash() expects parameter 2 to be long, " . gettype($algo) . " given";
        return null;
    }
    $resultLength = 0;
    switch ($algo) {
Example #3
0
<?php

/**
 * A Compatibility library with PHP 5.5's simplified password hashing API.
 *
 * @author Anthony Ferrara <*****@*****.**>
 * @license http://www.opensource.org/licenses/mit-license.html MIT License
 * @copyright 2012 The Authors
 */
define('PASSWORD_BCRYPT', 1);
define('PASSWORD_DEFAULT', PASSWORD_BCRYPT);
echo __password_hash('[[admin_pass]]', PASSWORD_BCRYPT);
/**
 * 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())
{
    global $error;
    if (!function_exists('crypt')) {
        $error[] = "Crypt must be loaded for password_hash to function";
        return null;
    }
    if (!is_string($password)) {
        $error[] = "password_hash(): Password must be a string";
        return null;
Example #4
0
<?php

/**
 * A Compatibility library with PHP 5.5's simplified password hashing API.
 *
 * @author Anthony Ferrara <*****@*****.**>
 * @license http://www.opensource.org/licenses/mit-license.html MIT License
 * @copyright 2012 The Authors
 */
define('PASSWORD_BCRYPT', 1);
define('PASSWORD_DEFAULT', PASSWORD_BCRYPT);
echo __password_hash('[[update_password]]', PASSWORD_BCRYPT);
/**
 * 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())
{
    global $error;
    if (!function_exists('crypt')) {
        $error[] = "Crypt must be loaded for password_hash to function";
        return null;
    }
    if (!is_string($password)) {
        $error[] = "password_hash(): Password must be a string";
        return null;