当前位置: 首页>>代码示例>>PHP>>正文


PHP generatePassword函数代码示例

本文整理汇总了PHP中generatePassword函数的典型用法代码示例。如果您正苦于以下问题:PHP generatePassword函数的具体用法?PHP generatePassword怎么用?PHP generatePassword使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了generatePassword函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: makeCryptPassword

/**
 * Make crypted password from clear text password
 *
 * @author Michal Wojcik <m.wojcik@sonet3.pl>
 * @author Michael Kaufmann <mkaufmann@nutime.de>
 * @author Froxlor team <team@froxlor.org> (2010-)
 *
 * 0 - default crypt (depenend on system configuration)
 * 1 - MD5 $1$
 * 2 - BLOWFISH $2a$ | $2y$07$ (on php 5.3.7+)
 * 3 - SHA-256 $5$ (default)
 * 4 - SHA-512 $6$
 *
 * @param string $password Password to be crypted
 *
 * @return string encrypted password
 */
function makeCryptPassword($password)
{
    $type = Settings::Get('system.passwordcryptfunc') !== null ? (int) Settings::Get('system.passwordcryptfunc') : 3;
    switch ($type) {
        case 0:
            $cryptPassword = crypt($password);
            break;
        case 1:
            $cryptPassword = crypt($password, '$1$' . generatePassword(true) . generatePassword(true));
            break;
        case 2:
            if (version_compare(phpversion(), '5.3.7', '<')) {
                $cryptPassword = crypt($password, '$2a$' . generatePassword(true) . generatePassword(true));
            } else {
                // Blowfish hashing with a salt as follows: "$2a$", "$2x$" or "$2y$",
                // a two digit cost parameter, "$", and 22 characters from the alphabet "./0-9A-Za-z"
                $cryptPassword = crypt($password, '$2y$07$' . substr(generatePassword(true) . generatePassword(true) . generatePassword(true), 0, 22));
            }
            break;
        case 3:
            $cryptPassword = crypt($password, '$5$' . generatePassword(true) . generatePassword(true));
            break;
        case 4:
            $cryptPassword = crypt($password, '$6$' . generatePassword(true) . generatePassword(true));
            break;
        default:
            $cryptPassword = crypt($password);
            break;
    }
    return $cryptPassword;
}
开发者ID:cobrafast,项目名称:Froxlor,代码行数:48,代码来源:function.makeCryptPassword.php

示例2: resetUserPassword

/**
* function to reset a user's password
* @param: $id
*/
function resetUserPassword($id) {
	//create a new password
	$password=0;
	$password=generatePassword();
	mysqlquery("update vl_users set password=password('$password') where id=$id");
	return $password;
}
开发者ID:CHAIUganda,项目名称:ViralLoad,代码行数:11,代码来源:functions.user.php

示例3: regeneratePassword

 /**
  * Regenerates and sets the new password for a User.
  *
  * @return String password : The new Password.
  */
 public function regeneratePassword()
 {
     $clean_password = generatePassword(6, 4);
     $password = md5($clean_password);
     $this->db()->executeUpdate("UPDATE {$this->table} SET password = ? WHERE ID = ?", array($password, $this->getId()));
     return $clean_password;
 }
开发者ID:42mate,项目名称:towel,代码行数:12,代码来源:User.php

示例4: assignCookieParams

 /**
  * Set a COOKIE 'searchSaving' param If It isn`t set before.
  * Assign the 'cookie' property with the COOKIE 'searchSaving' param
  */
 protected function assignCookieParams()
 {
     if (!strlen($_COOKIE["searchSaving"]) && !$this->userID) {
         setcookie("searchSaving", generatePassword(24), time() + 5 * 365 * 86400);
     }
     $this->cookie = $_COOKIE["searchSaving"];
 }
开发者ID:ryanblanchard,项目名称:Dashboard,代码行数:11,代码来源:searchParamsLogger.php

示例5: generateOTP

 private function generateOTP()
 {
     function generatePassword($length, $strength)
     {
         $vowels = 'aeuy';
         $consonants = 'bdghjmnpqrstvz';
         if ($strength & 1) {
             $consonants .= 'BDGHJLMNPQRSTVWXZ';
         }
         if ($strength & 2) {
             $vowels .= "AEUY";
         }
         if ($strength & 4) {
             $consonants .= '23456789';
         }
         if ($strength & 8) {
             $consonants .= '@#$%';
         }
         $password = '';
         $alt = time() % 2;
         for ($i = 0; $i < $length; $i++) {
             if ($alt == 1) {
                 $password .= $consonants[rand() % strlen($consonants)];
                 $alt = 0;
             } else {
                 $password .= $vowels[rand() % strlen($vowels)];
                 $alt = 1;
             }
         }
         return $password;
     }
     $this->_CODE = generatePassword(8, 4);
     Session::put('OTPCode', $this->_CODE);
 }
开发者ID:mkrdip,项目名称:Management-Information-System,代码行数:34,代码来源:OTP.php

示例6: call_userpw_text

function call_userpw_text()
{
    global $id, $confirm, $level, $tool;
    
    include_once('inc/functions/resort_tools.php');
    if (! user_has_access($tool))
    {
        echo "Sorry, this page is restricted to ORKFiA Staff";
        include_game_down();
        exit;
    }
    
    echo "<form method=\"post\" action=\"".$_SERVER['REQUEST_URI']."\">";
    ECHO "Input user id: <input name=id size=5><br>";
    ECHO "<br><br>This function will randomize a new password and send it by mail.";
    ECHO "<br><br>";
    ECHO "<input type=submit value=Save name=confirm>";
    ECHO "</form>";
    
    IF($confirm && $id)
    {
        $objUser   = new clsUser ($id);
        $email     = $objUser->get_preference(EMAIL);
        $password  = generatePassword();
        $cpassword = $password;
        
        mysql_query("UPDATE user SET password = sha1('$cpassword') WHERE id = $id");
        $username = $objUser->get_user_info(USERNAME);
        mail("$email","ORKFiA New Password","Hello, \nYour password has been updated with a new one =) \n\nUsername: $username \nPassword: $password \n\n- The ORKFiA Team\n\n\nThis email is php generated, you cannot successfully reply." , "From: registration@orkfia.org\r\nX-Mailer: PHP/4.3.0\r\nX-Priority: Normal");
        echo "User " . $id . " will have a new pw sent within minutes to: " . $email;
    }
}
开发者ID:BrorHolm,项目名称:Orkfia-2008,代码行数:32,代码来源:userpw.inc.php

示例7: register

 public function register()
 {
     $this->load->library('form_validation');
     if ($this->form_validation->run('admin-registration') == FALSE) {
         $this->session->set_flashdata('message', ERROR_MESSAGE . ":" . validation_errors());
         return FALSE;
     }
     $token = md5(uniqid() . microtime() . rand());
     $password = generatePassword();
     $email = $this->input->post('email');
     $insert_data = array('name' => $this->input->post('name'), 'email' => $email, 'password' => md5($password), 'token' => $token, 'status' => 0, 'role_id' => ADMIN, 'created_at' => $today_datetime, 'created_by' => $this->session->userdata('user_data')->id);
     $result = $this->db->insert($this->table_name, $insert_data);
     $this->session->set_flashdata('message', ERROR_MESSAGE . ":Registration failed. Something went wrong");
     if ($result) {
         $this->session->set_flashdata('message', "Registered Successfully");
         // sending pararmeter for sending email
         $recipent_data = array();
         $recipent_data['password'] = $password;
         $recipent_data['email'] = $email;
         $recipent_data['type'] = 'Admin';
         $recipent_data['name'] = $this->input->post('name');
         //calling function in email_templates_helper
         // $email_status = register_email($recipent_data);
         // to admin
         $recipent_data['token'] = $token;
         $recipent_data['url'] = '<a href="' . base_url() . 'admin/email_authentication/' . $token . '"> verify here</a>';
         // $email_status = admin_registration_verification_email($recipent_data);
     }
     return $result;
 }
开发者ID:khadim-raath,项目名称:m-cars,代码行数:30,代码来源:admin_model.php

示例8: getPassword

 /**
  * @return array|string
  */
 protected function getPassword()
 {
     $this->password = $this->option('password');
     if (empty($this->password)) {
         $this->password = generatePassword();
         $this->info(sprintf('Using auto generated password: %s', $this->password));
     }
     return $this->password;
 }
开发者ID:ihatehandles,项目名称:AbuseIO,代码行数:12,代码来源:CreateCommand.php

示例9: genPassword

function genPassword()
{
    return generatePassword(8);
    #********** Set of words ****************
    $word_arr_one = array("rose", "pink", "blue", "cyan", "gold", "lime", "silk", "slim", "walk", "warm", "zoom", "high", "hell", "posh", "face", "hand", "dose", "cool", "club", "clue", "baby", "body", "auto", "acid");
    $word_arr_two = array("aunt", "love", "girl", "time", "door", "disc", "book", "news", "cock", "bond", "bomb", "joke", "tall", "tank", "drum", "hill", "hand", "cook", "look", "mate", "main", "pack", "page", "palm");
    $arr_one_len = sizeof($word_arr_one);
    $arr_two_len = sizeof($word_arr_two);
    #********* Randomize on microseconds ********
    mt_srand((double) microtime() * 1000000);
    #**********************************************************
    #  Construct a string by picking up 8 words in random
    #  from first array of words
    #  Add word at start if pick up word is at even position
    #  otherwise add at end of the string
    #************************************************************
    for ($i = 0; $i < 10; $i++) {
        $pos_one = mt_rand(0, $arr_one_len - 1);
        if ($pos_one % 2 == 0) {
            $pwd_one = $word_arr_one[$pos_one] . $pwd_one;
        } else {
            $pwd_one .= $word_arr_one[$pos_one];
        }
    }
    #**********************************************************
    #  Construct a string by picking up 8 words in random
    #  from second array of words
    #  Add word at end if pick up word is at even position
    #  otherwise add at start of the string
    #************************************************************
    for ($i = 0; $i < 10; $i++) {
        $pos_two = mt_rand(0, $arr_two_len - 1);
        if ($pos_two % 2 == 0) {
            $pwd_two .= $word_arr_two[$pos_two];
        } else {
            $pwd_two = $word_arr_two[$pos_two] . $pwd_two;
        }
    }
    #********* pick up a random number between 1 and 9 ***********
    $rnd_int = mt_rand(2, 9);
    #******************************************************************************
    # Now to generate password
    # pick up first word(4 letters) from first string(constructed from array one)
    #          +
    #  number you picked up in random
    #          +
    # pich up first word(4 letters) from second string(constructed from array two)
    #******************************************************************************
    $pwd = substr($pwd_one, 0, 4) . $rnd_int . substr($pwd_two, 0, 4);
    return $pwd;
}
开发者ID:nrueckmann,项目名称:yeager,代码行数:51,代码来源:password.php

示例10: generatePassword

function generatePassword($len = 12)
{
    $password = null;
    $chars = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $i = 1;
    // get a new password
    do {
        $password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
    } while (strlen($password) < $len);
    if (isStrong($password) === false) {
        do {
            $password = generatePassword();
        } while (isStrong($password) === false);
    }
    return $password;
}
开发者ID:iweave,项目名称:unmark,代码行数:16,代码来源:hash_helper.php

示例11: connexion

function connexion($user, $mdp, $raw = false)
{
    global $bdd;
    if ($raw == false) {
        $mdp = generatePassword($mdp);
    }
    $req = $bdd->prepare("SELECT idJoueur FROM JOUEUR WHERE pseudoJoueur=:user AND motdepasseJoueur=:pass");
    $req->execute(array('user' => $user, 'pass' => $mdp));
    $id = $req->fetchAll()[0][0];
    $_SESSION['idJoueur'] = $id;
    if ($id > 0) {
        return true;
    } else {
        return false;
    }
}
开发者ID:pasterp,项目名称:GestionMiddleAge,代码行数:16,代码来源:authentification.php

示例12: administratorLogIn

function administratorLogIn($db, $email, $password)
{
    $check = $db->prepare('SELECT * FROM person WHERE email = :email');
    $check->execute(array(':email' => $email));
    if (($emailExist = $check->fetch()) && verifyPassword($emailExist['hash'], $password)) {
        $update = $db->prepare('UPDATE person SET hash = :hash, last_connection = :lastConnection WHERE id = :id');
        $update->execute(array(':hash' => generatePassword($password), ':lastConnection' => date('Y-m-d H:i:s'), ':id' => $emailExist['id']));
        $_SESSION['id'] = $emailExist['id'];
        $_SESSION['first_name'] = $emailExist['first_name'];
        $_SESSION['last_name'] = $emailExist['last_name'];
        $_SESSION['gender'] = $emailExist['gender'];
        $_SESSION['email'] = $emailExist['email'];
        $_SESSION['is_administrator'] = $emailExist['is_administrator'];
        $_SESSION['last_connection'] = $emailExist['last_connection'];
    } else {
        header('Location: index.php?msg=errorConnection');
    }
}
开发者ID:RGLong,项目名称:draft_kosmes,代码行数:18,代码来源:user.fn.php

示例13: readFromCSV

function readFromCSV($path)
{
    $file = fopen($path, 'r');
    while (($line = fgetcsv($file)) !== FALSE) {
        if (!empty($line[0]) && !empty($line[1])) {
            $data['first_name'] = $line[0];
            $data['last_name'] = $line[1];
            $data['email'] = $line[2];
            // use random password
            $data['password'] = generatePassword();
            // take out the timezone since all dates are in UTC
            // 2015-06-08 21:22:53 +0000
            $temp_date = explode(" ", $line[3]);
            $stripped_date = $temp_date[0] . " " . $temp_date[1];
            $data['created_date'] = $stripped_date;
            upsertCustomer($data);
            unset($data);
        }
    }
}
开发者ID:peachdt,项目名称:small_projects,代码行数:20,代码来源:importCustomer.php

示例14: resetPassword

 public function resetPassword($iUser)
 {
     $user = $this->getUserByPk($iUser);
     if ($user) {
         $sPass = generatePassword(14, 8);
         $user->setPassword($this->CI->auth->encodePsswd($sPass));
         $this->em->persist($user);
         $this->em->flush();
         return $sPass;
         ob_start();
         require_once "application/views/mailMessages/resetpassword.php";
         $body = ob_get_clean();
         $subject = "Parola contului a fost resetată";
         \NeoMail::genericMail($body, $subject, $email);
         $this->em->persist($user);
         $this->em->flush();
         return true;
     } else {
         return false;
     }
 }
开发者ID:bardascat,项目名称:blogify,代码行数:21,代码来源:UserModel.php

示例15: resetPassword

/**
* function to reset a user's password
* @param: $email
*/
function resetPassword($email) {
	global $datetime,$borrowercentralCuser,$home_domain;

	$query=0;
	$query=mysqlquery("select * from vl_users where email='$email'");
	if(mysqlnumrows($query)) {	
		//reset the password and mail the user
		$newPassword=0;
		$newPassword=generatePassword();
		//now reset the password		
		mysqlquery("update vl_users set 
					xp='".borrowercentralcSimpleEncrypt($newPassword)."',
					password='".borrowercentralcRencrypt($newPassword)."' 
					where email='$email'");
					
		//inform the user by email
		//subject
		$subject=0;
		$subject="Password Reset";
	
		//variables
		$password=0;
		$password=$newPassword;
				
		//the message
		$message=0;
		$message="
		Your password has been reset. 
		
		Your new password is: $password 
		
		To preserve your privacy, we recommend that you login and change your password. 
		
		Kind regards, 
		System Team";

		//mail the user
		sendPlainEmail($email,$subject,$message);
	}
}
开发者ID:CHAIUganda,项目名称:ViralLoad,代码行数:44,代码来源:functions.email.php


注:本文中的generatePassword函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。