本文整理汇总了PHP中generatePassword函数的典型用法代码示例。如果您正苦于以下问题:PHP generatePassword函数的具体用法?PHP generatePassword怎么用?PHP generatePassword使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generatePassword函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: makeCryptPassword
/**
* Make crypted password from clear text password
*
* @author Michal Wojcik <[email protected]>
* @author Michael Kaufmann <[email protected]>
* @author Froxlor team <[email protected]> (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: [email protected]\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
示例16: login
function login()
{
$this->form_validation->set_rules('username', 'username', 'trim|required', '');
$this->form_validation->set_rules('password', 'password', 'trim|required', '');
$this->form_validation->set_error_delimiters('<div class="remember-me">', '</div>');
if ($this->form_validation->run() == FALSE) {
$this->load->view('index');
} else {
$this->load->model('model_login');
$hash_passwd = generatePassword($this->input->post('password'));
$result = $this->model_login->admin_login($this->input->post('username'), $hash_passwd);
if ($result) {
foreach ($result as $row) {
$this->session->set_userdata(array('logged_in' => TRUE, 'user_id' => $row->user_id, 'user_first_name' => $row->user_first_name, 'user_last_name' => $row->user_last_name, 'user_email' => $row->user_email, 'user_type' => $row->user_type));
}
redirect($this->config->item('base_url') . 'dashboard');
} else {
$this->session->set_flashdata('message', _erMsg2('<h5 style="color:red">You Have Entered Invalid Credentials</h5>'));
redirect($this->config->item('base_url') . 'index');
}
}
}
开发者ID:CreatrixeNew,项目名称:carparking,代码行数:22,代码来源:index.php
示例17: ReadAccountFile
function ReadAccountFile()
{
global $ACCOUNT_FILE;
global $users;
$users = array();
$fp = fopen($ACCOUNT_FILE, "rt");
if ($fp == false) {
exit(-1);
}
while (!feof($fp)) {
$delim = " \t\n\r";
$buf = fgets($fp, 1024);
$id = strtok($buf, $delim);
if ($id == false) {
continue;
}
$name = strtok($delim);
if ($name == false) {
continue;
}
$dept = strtok($delim);
if ($dept == false) {
continue;
}
$email = strtok($delim);
if ($email == false) {
continue;
}
$pwd = strtok($delim);
//if ( $pwd == false)
$pwd = generatePassword(13, 4);
$users[$id]['name'] = $name;
$users[$id]['dept'] = $dept;
$users[$id]['email'] = $email;
$users[$id]['pwd'] = $pwd;
}
fclose($fp);
// print_r($users);
}
开发者ID:senselab,项目名称:CodeSensor,代码行数:39,代码来源:GenPwd.php
示例18: insert
function insert()
{
global $prepare_query_insert;
$pass = generatePassword();
$sha_pass = SHA1(strtoupper($_POST['user']) . ':' . strtoupper($pass));
try {
$prepare_query_insert->execute(array(':pass' => $sha_pass, ':name' => $_POST['user']));
} catch (Exception $e) {
exit("<div align=\"center\"><font color=\"red\">Erreur lors de la requête pour la mise à jour !<br />Message d'erreur : " . $e->getMessage() . "</font></div>");
}
$sujet = "Votre nouveau mot de passe";
$corps = "Bonjour,\n,Suite à votre demande de réinitialisation de mot de passe,\nNous vous fournissons votre nouveau mot de passe :\n " . $pass . " \nSi vous n'avez jamais demandé une réinitialisation de mot de passe, veuillez nous contacter au plus vite !\nCordialement,l'équipe du serveur.";
global $array_site;
$headers = "From: " . $array_site['email'];
ini_set('SMTP', $array_site['smtp']);
ini_set('smtp_port', $array_site['smtp_port']);
if (mail($_POST['email'], $sujet, $corps, $headers)) {
return true;
} else {
exit("<div align=\"center\"><font color=\"red\">Erreur lors de l'envoi de l'email. Veuillez contacter l'administrateur</font></div>");
}
}
开发者ID:pauljenny,项目名称:NoCMS,代码行数:22,代码来源:reset_mdp.php
示例19: check
function check($user, $pass)
{
try {
$db = new SQLite3(':memory:');
$db->query('CREATE TABLE IF NOT EXISTS users (username TEXT, password TEXT)');
$us = array('admin', 'user', 'member', 'bob');
foreach ($us as $u) {
$db->query("INSERT INTO users (username, password) SELECT '" . $u . "', '" . generatePassword() . "' WHERE NOT EXISTS (SELECT 1 FROM users WHERE username = '" . $u . "')");
}
if (strlen($user) > 32 || strlen($pass) > 32) {
res('Username or password too long!');
}
$res = $db->query("SELECT COUNT(*) FROM users WHERE username = '{$user}' AND password = '{$pass}'");
if (!$res) {
res('SQL Error: ' . $db->lastErrorMsg());
}
$row = $res->fetchArray();
return $row[0] != 0;
} catch (Exception $e) {
res('Error: ' . $e->getMessage());
error_log($e);
}
}
开发者ID:arthaud,项目名称:write-ups-2016,代码行数:23,代码来源:index.php
示例20: antispam
function antispam(&$object, $params)
{
global $modx;
$fields = array('address', 'captcha', 'emailConfirm', 'emailCheck', 'easyCaptcha', 'email-retype', 'emailRetype', 'email2', 'nickName', 'siteAddress', 'siteUrl', 'url1');
$fieldName = $fields[array_rand($fields)];
$className = 'jot-form-' . generatePassword();
$found = false;
switch ($object->event) {
case 'onBeforePOSTProcess':
foreach ($fields as $val) {
if (isset($_POST[$val]) && empty($_POST[$val])) {
$found = true;
}
}
if (!$found) {
$object->form['error'] = 4;
$object->form['confirm'] = 0;
return true;
}
break;
case 'onSetFormOutput':
$block = '
<div class="' . $className . '">
<input type="text" name="' . $fieldName . '" value="" size="40" />
</div>
</form>';
$css = '<style type="text/css">.' . $className . ' {left:0; position:absolute; top:-500px; width:1px; height:1px; overflow:hidden; visibility:hidden;}</style>';
if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') {
$modx->regClientCSS($css);
} else {
$block .= $css;
}
$object->config["html"]["form"] = str_replace('</form>', $block, $object->config["html"]["form"]);
break;
}
}
开发者ID:Zevseg,项目名称:JotX,代码行数:36,代码来源:antispam.inc.php
注:本文中的generatePassword函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论