• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP generate_salt函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: register

 public function register()
 {
     check_if_already_logged_in();
     $data["page"] = "register";
     if (isset($_POST['btnRegister'])) {
         $input = array("username" => $_POST['username'], "password" => $_POST['password'], "confirmpass" => $_POST['password_confirm'], "firstname" => $_POST['firstname'], "middlename" => $_POST['middlename'], "lastname" => $_POST['lastname'], "email" => $_POST['email'], "gender" => isset($_POST['gender']) ? $_POST['gender'] : "", "occupation" => $_POST['occupation'], "otherinfo" => $_POST['otherinfo']);
         $data["error"] = verify_data($input);
         if ($data["error"]["count"] == 0) {
             $salt = generate_salt();
             $userdata["username"] = $input["username"];
             $userdata["salt"] = encrypt_salt($salt, 'enElpiPUP1516');
             $userdata["password"] = hash_password($input["password"], $salt);
             $userdata["type"] = "member";
             $other["first_name"] = $input["firstname"];
             $other["middle_name"] = $input["middlename"];
             $other["last_name"] = $input["lastname"];
             $other["email"] = $input["email"];
             $other["gender"] = $input["gender"];
             $other["occupation"] = $input["occupation"];
             $other["about"] = $input["otherinfo"];
             $user = $this->Users_model->insert($userdata, $other);
             header('Location: register');
         }
     }
     $this->load->view('templates/header');
     $this->load->view('users/register', $data);
     $this->load->view('templates/footer');
 }
开发者ID:aldsdelram,项目名称:PUPNLPWebsite,代码行数:28,代码来源:Users.php


示例2: add_user

function add_user($username, $password, $email)
{
    global $conn;
    $salt = generate_salt();
    $password_hash = hash("sha256", $password . $salt);
    $query = "INSERT INTO login_data (username, password_hash, salt, email) VALUES ('{$username}', '{$password_hash}', '{$salt}', '{$email}');";
    mysqli_query($conn, $query) or die(mysqli_error($conn));
}
开发者ID:ericpts,项目名称:ericpts.github.io,代码行数:8,代码来源:db.php


示例3: user_register

function user_register($username, $password, $email)
{
    $salt = generate_salt();
    $encrypted = md5(md5($password) . $salt);
    //	$query = "INSERT into users (username, password, salt) values ('$username', '$encrypted', '$salt')";
    $query = "INSERT into users (username, password, salt, email) values ('{$username}', '{$encrypted}', '{$salt}', '{$email}')";
    mysql_query($query) or die('Could not create user.');
}
开发者ID:reinfurt,项目名称:MOLLYS,代码行数:8,代码来源:systemLogin.php


示例4: new_user

function new_user($firstName, $lastName, $email, $password, $userType)
{
    $salt = generate_salt();
    $encPassword = encrypt_password($password, $salt);
    $user = create_user_object($firstName, $lastName, $email, $encPassword, $salt, $userType);
    save_user_object($user);
    return $user;
}
开发者ID:JXHZY,项目名称:webDeveloper,代码行数:8,代码来源:data_service.php


示例5: password_encrypt

function password_encrypt($password)
{
    $hash_format = "\$2y\$10\$";
    $salt_length = 22;
    $salt = generate_salt($salt_length);
    $format_and_salt = $hash_format . $salt;
    $hash = crypt($password, $format_and_salt);
    return $hash;
}
开发者ID:rodneywells01,项目名称:NickWeb,代码行数:9,代码来源:functions.php


示例6: convert_data

 function convert_data($data)
 {
     $insert_data = array();
     // phpBB 2 values
     $insert_data['usergroup'] = $this->board->get_group_id($data, array("not_multiple" => true));
     $insert_data['additionalgroups'] = str_replace($insert_data['usergroup'], '', $this->board->get_group_id($data));
     $insert_data['displaygroup'] = $this->board->get_group_id($data, array("not_multiple" => true));
     $insert_data['import_usergroup'] = $this->board->get_group_id($data, array("not_multiple" => true, "original" => true));
     $insert_data['import_additionalgroups'] = $this->board->get_group_id($data, array("original" => true));
     $insert_data['import_displaygroup'] = $data['group_id'];
     $insert_data['import_uid'] = $data['user_id'];
     $insert_data['username'] = encode_to_utf8($data['username'], "users", "users");
     $insert_data['email'] = $data['user_email'];
     $insert_data['regdate'] = $data['user_regdate'];
     $insert_data['lastactive'] = $data['user_lastvisit'];
     $insert_data['lastvisit'] = $data['user_lastvisit'];
     $insert_data['website'] = $data['user_website'];
     $insert_data['avatar'] = $data['user_avatar'];
     list($width, $height) = @getimagesize($data['user_avatar']);
     $insert_data['avatardimensions'] = $width . '|' . $height;
     if ($insert_data['avatar'] == '') {
         $insert_data['avatartype'] = "";
     } else {
         $insert_data['avatartype'] = 'remote';
     }
     $last_post = $this->get_last_post($data['user_id']);
     $insert_data['lastpost'] = intval($last_post['post_time']);
     $insert_data['icq'] = $data['user_icq'];
     $insert_data['aim'] = $data['user_aim'];
     $insert_data['yahoo'] = $data['user_yim'];
     $insert_data['msn'] = $data['user_msnm'];
     $insert_data['hideemail'] = $data['hideEmail'];
     $insert_data['invisible'] = int_to_01($data['user_allow_viewonline']);
     $insert_datar['allownotices'] = $data['user_notify'];
     if ($data['user_notify'] == 1) {
         $subscription_method == 2;
     } else {
         $subscription_method = 0;
     }
     $insert_data['subscriptionmethod'] = $subscription_method;
     $insert_data['receivepms'] = $data['user_allow_pm'];
     $insert_data['pmnotice'] = $data['user_popup_pm'];
     $insert_data['pmnotify'] = $data['pm_email_notify'];
     $insert_data['showsigs'] = $data['user_attachsig'];
     $insert_data['showavatars'] = $data['user_allowavatar'];
     $insert_data['timeformat'] = $data['user_dateformat'];
     $insert_data['timezone'] = $data['user_timezone'];
     $insert_data['regip'] = $last_post['poster_ip'];
     $insert_data['totalpms'] = $this->get_private_messages($data['user_id']);
     $insert_data['unreadpms'] = $data['user_unread_privmsg'];
     $insert_data['salt'] = generate_salt();
     $insert_data['signature'] = encode_to_utf8(str_replace(':' . $data['user_sig_bbcode_uid'], '', utf8_unhtmlentities($data['user_sig'])), "users", "users");
     $insert_data['password'] = salt_password($data['user_password'], $insert_data['salt']);
     $insert_data['loginkey'] = generate_loginkey();
     return $insert_data;
 }
开发者ID:dgrp,项目名称:merge-system,代码行数:56,代码来源:users.php


示例7: password_encrypt

function password_encrypt($password)
{
    $hash_format = "\$2y\$10\$";
    $length = 22;
    //generate salt function of length 22
    $salt = generate_salt($length);
    $format_and_salt = $hash_format . $salt;
    $hashed_password = crypt($password, $format_and_salt);
    return $hashed_password;
}
开发者ID:arnavprospeed,项目名称:Assignment_17_08_2015,代码行数:10,代码来源:functions_repo.php


示例8: password_encrypt

function password_encrypt($password)
{
    $hash_format = "\$2a\$05\$";
    //blowfish
    $salt = generate_salt();
    $format_and_salt = $hash_format . $salt;
    //crypt using password and 22 characters (salt and blowfish)
    $hash = crypt($password, $format_and_salt);
    return $hash;
}
开发者ID:sabalbhati,项目名称:DiscoverMoreMusic,代码行数:10,代码来源:ep_function.php


示例9: user_register

function user_register($username, $password, $email, $youtubeUserName)
{
    // Get a salt using our function
    $salt = generate_salt();
    // Now encrypt the password using that salt
    $encrypted = md5(md5($password) . $salt);
    // And lastly, store the information in the database
    $ref = $_SESSION['ref'];
    $query = "insert into user (username, password, salt, email, youtubeUserName, video, refferal) values ('{$username}', '{$encrypted}', '{$salt}', '{$email}', '{$youtubeUserName}', '', '{$ref}')";
    mysql_query($query) or die('Could not create user. Refresh the page to try again.');
}
开发者ID:danielheyman,项目名称:EazySubs,代码行数:11,代码来源:functions.php


示例10: change_password

 public function change_password(IChangePasswordInput $input)
 {
     // Prepare data
     $this->load->helper('crypto');
     $passwordsalt = generate_salt();
     $passwordhash = generate_hash($input->get_password(), $passwordsalt);
     $this->db->where('email', $input->get_email());
     $this->db->where('passwordresetcode', $input->get_resetcode());
     $this->db->update("users", array("passwordresetcode" => NULL, "passwordhash" => $passwordhash, "passwordsalt" => $passwordsalt));
     return $this->db->affected_rows() > 0;
 }
开发者ID:git-ecorise,项目名称:snp,代码行数:11,代码来源:UserModel.php


示例11: verify_password

function verify_password($password, $salt, $uid = false)
{
    $correct = false;
    if (substr($salt, 0, 1) == '$') {
        // new-style crypt()
        $correct = crypt($password, $salt) == $salt;
    } elseif (substr($salt, 0, 7) == '{crypt}') {
        // old-style crypt() with DES and static salt - not used anymore
        $correct = crypt($password, '77') == $salt;
    } elseif (strlen($salt) == 32) {
        // old-style md5 without salt - not used anymore
        $correct = md5($password) == $salt;
    }
    if ($correct && substr($salt, 0, strlen(CRYPT_ALG)) != CRYPT_ALG && $uid) {
        // this password is stored in another format than we want it to be.
        // let's update it!
        // we duplicate the query from the above set_password() function to have the extra safety of checking the old hash
        sql_query("UPDATE `User` SET `Passwort` = '" . sql_escape(crypt($password, CRYPT_ALG . '$' . generate_salt() . '$')) . "' WHERE `UID` = " . intval($uid) . " AND `Passwort` = '" . sql_escape($salt) . "' LIMIT 1");
    }
    return $correct;
}
开发者ID:max-weller,项目名称:engelsystem,代码行数:21,代码来源:sys_auth.php


示例12: loginconvert_convert

function loginconvert_convert(&$login)
{
    global $mybb, $valid_login_types, $db, $settings;
    $options = array("fields" => array('username', "password", "salt", 'loginkey', 'coppauser', 'usergroup', "passwordconvert", "passwordconverttype", "passwordconvertsalt"), "username_method" => (int) $settings['username_method']);
    if ($login->username_method !== null) {
        $options['username_method'] = (int) $login->username_method;
    }
    $user = get_user_by_username($login->data['username'], $options);
    // There's nothing to check for, let MyBB do everything
    // This fails also when no user was found above, so no need for an extra check
    if (!isset($user['passwordconvert']) || $user['passwordconvert'] == '') {
        return;
    }
    if (!array_key_exists($user['passwordconverttype'], $valid_login_types)) {
        // TODO: Is there an easy way to make the error translatable without adding a new language file?
        redirect($mybb->settings['bburl'] . "/member.php?action=lostpw", "We're sorry but we couldn't convert your old password. Please select a new one", "", true);
    } else {
        $function = "check_" . $valid_login_types[$user['passwordconverttype']];
        $check = $function($login->data['password'], $user);
        if (!$check) {
            // Yeah, that function is called later too, but we need to know whether the captcha is right
            // If we wouldn't call that function the error would always be shown
            $login->verify_attempts($mybb->settings['captchaimage']);
            $login->invalid_combination(true);
        } else {
            // The password was correct, so use MyBB's method the next time (even if the captcha was wrong we can update the password)
            $salt = generate_salt();
            $update = array("salt" => $salt, "password" => salt_password(md5($login->data['password']), $salt), "loginkey" => generate_loginkey(), "passwordconverttype" => "", "passwordconvert" => "", "passwordconvertsalt" => "");
            $db->update_query("users", $update, "uid='{$user['uid']}'");
            // Make sure the password isn't tested again
            unset($login->data['password']);
            // Also make sure all data is available when creating the session (otherwise SQL errors -.-)
            $login->login_data = array_merge($user, $update);
        }
    }
}
开发者ID:ateista-pl,项目名称:forum,代码行数:36,代码来源:loginconvert.php


示例13: process_account_form


//.........这里部分代码省略.........
        if ($TYPE == "edit") {
            $q .= " AND ID != " . intval($UID);
        }
        $result = $dbh->query($q);
        $row = $result->fetch(PDO::FETCH_NUM);
        if ($row[0]) {
            $error = __("The address, %s%s%s, is already in use.", "<strong>", htmlspecialchars($E, ENT_QUOTES), "</strong>");
        }
    }
    if (!$error && count($ssh_keys) > 0) {
        /*
         * Check whether any of the SSH public keys is already in use.
         * TODO: Fix race condition.
         */
        $q = "SELECT Fingerprint FROM SSHPubKeys ";
        $q .= "WHERE Fingerprint IN (";
        $q .= implode(',', array_map(array($dbh, 'quote'), $ssh_fingerprints));
        $q .= ")";
        if ($TYPE == "edit") {
            $q .= " AND UserID != " . intval($UID);
        }
        $result = $dbh->query($q);
        $row = $result->fetch(PDO::FETCH_NUM);
        if ($row) {
            $error = __("The SSH public key, %s%s%s, is already in use.", "<strong>", htmlspecialchars($row[0], ENT_QUOTES), "</strong>");
        }
    }
    if ($error) {
        $message = "<ul class='errorlist'><li>" . $error . "</li></ul>\n";
        return array(false, $message);
    }
    if ($TYPE == "new") {
        /* Create an unprivileged user. */
        $salt = generate_salt();
        if (empty($P)) {
            $send_resetkey = true;
            $email = $E;
        } else {
            $send_resetkey = false;
            $P = salted_hash($P, $salt);
        }
        $U = $dbh->quote($U);
        $E = $dbh->quote($E);
        $P = $dbh->quote($P);
        $salt = $dbh->quote($salt);
        $R = $dbh->quote($R);
        $L = $dbh->quote($L);
        $I = $dbh->quote($I);
        $K = $dbh->quote(str_replace(" ", "", $K));
        $q = "INSERT INTO Users (AccountTypeID, Suspended, ";
        $q .= "InactivityTS, Username, Email, Passwd, Salt, ";
        $q .= "RealName, LangPreference, IRCNick, PGPKey) ";
        $q .= "VALUES (1, 0, 0, {$U}, {$E}, {$P}, {$salt}, {$R}, {$L}, ";
        $q .= "{$I}, {$K})";
        $result = $dbh->exec($q);
        if (!$result) {
            $message = __("Error trying to create account, %s%s%s.", "<strong>", htmlspecialchars($U, ENT_QUOTES), "</strong>");
            return array(false, $message);
        }
        $uid = $dbh->lastInsertId();
        account_set_ssh_keys($uid, $ssh_keys, $ssh_fingerprints);
        $message = __("The account, %s%s%s, has been successfully created.", "<strong>", htmlspecialchars($U, ENT_QUOTES), "</strong>");
        $message .= "<p>\n";
        if ($send_resetkey) {
            send_resetkey($email, true);
            $message .= __("A password reset key has been sent to your e-mail address.");
开发者ID:pyp22,项目名称:aurweb,代码行数:67,代码来源:acctfuncs.inc.php


示例14: gen_mix_salt

function gen_mix_salt($pass)
{
    $salt = generate_salt();
    return mix_salt($salt, $pass);
}
开发者ID:jelastic-public-cartridges,项目名称:jelastic-powerdns-cartridge,代码行数:5,代码来源:toolkit.inc.php


示例15: i18n_r

        }
        $langs .= '<option ' . $sel . ' value="' . $larray . '" >' . $larray . '</option>';
        $sel = '';
        $count++;
    }
    $langs .= '</select><br />';
} else {
    $langs = '<b>' . i18n_r('LANGUAGE') . '</b>: &nbsp;<code style="color:red;">' . i18n_r('NONE') . '</code> &nbsp;&nbsp;';
}
# salt value generation
$api_file = GSDATAOTHERPATH . GSAUTHFILE;
if (!file_exists($api_file)) {
    if (getDef('GSUSECUSTOMSALT')) {
        $saltval = sha1(GSUSECUSTOMSALT);
    } else {
        $saltval = generate_salt();
    }
    $xml = new SimpleXMLExtended('<item></item>');
    $note = $xml->addChild('apikey');
    $note->addCData($saltval);
    if (!XMLsave($xml, $api_file)) {
        $kill = i18n_r('CHMOD_ERROR');
    }
}
# get salt value
$data = getXML($api_file);
$APIKEY = $data->apikey;
if (empty($APIKEY)) {
    $kill = i18n_r('CHMOD_ERROR');
}
$pagetitle = $site_full_name . ' &middot; ' . i18n_r('INSTALLATION');
开发者ID:kix23,项目名称:GetSimpleCMS,代码行数:31,代码来源:install.php


示例16: update_salt

/**
 * Updates a user's salt in the database (does not update a password).
 *
 * @param int $uid The uid of the user to update.
 * @return string The new salt.
 */
function update_salt($uid)
{
    global $db;
    $salt = generate_salt();
    $sql_array = array("salt" => $salt);
    $db->update_query("users", $sql_array, "uid='{$uid}'");
    return $salt;
}
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:14,代码来源:functions_user.php


示例17: insert

 /**
  * Insert a new provider record into the database.
  *  
  * @param array $provider Contains the provider data (must be already validated).
  * @return int Returns the new record id.
  * @throws Exception When the insert operation fails.
  */
 public function insert($provider)
 {
     $this->load->helper('general');
     // Get provider role id.
     $provider['id_roles'] = $this->get_providers_role_id();
     // Store provider settings and services (must not be present on the $provider array).
     $services = $provider['services'];
     unset($provider['services']);
     $settings = $provider['settings'];
     unset($provider['settings']);
     // Insert provider record and save settings.
     if (!$this->db->insert('ea_users', $provider)) {
         throw new Exception('Could not insert provider into the database');
     }
     $settings['salt'] = generate_salt();
     $settings['password'] = hash_password($settings['salt'], $settings['password']);
     $provider['id'] = $this->db->insert_id();
     $this->save_settings($settings, $provider['id']);
     $this->save_services($services, $provider['id']);
     // Return the new record id.
     return intval($provider['id']);
 }
开发者ID:pyrix,项目名称:appointments,代码行数:29,代码来源:providers_model.php


示例18: mod_user_new

function mod_user_new()
{
    global $pdo, $config;
    if (!hasPermission($config['mod']['createusers'])) {
        error($config['error']['noaccess']);
    }
    if (isset($_POST['username'], $_POST['password'], $_POST['type'])) {
        if ($_POST['username'] == '') {
            error(sprintf($config['error']['required'], 'username'));
        }
        if ($_POST['password'] == '') {
            error(sprintf($config['error']['required'], 'password'));
        }
        if (isset($_POST['allboards'])) {
            $boards = array('*');
        } else {
            $_boards = listBoards();
            foreach ($_boards as &$board) {
                $board = $board['uri'];
            }
            $boards = array();
            foreach ($_POST as $name => $value) {
                if (preg_match('/^board_(' . $config['board_regex'] . ')$/u', $name, $matches) && in_array($matches[1], $_boards)) {
                    $boards[] = $matches[1];
                }
            }
        }
        $type = (int) $_POST['type'];
        if (!isset($config['mod']['groups'][$type]) || $type == DISABLED) {
            error(sprintf($config['error']['invalidfield'], 'type'));
        }
        $salt = generate_salt();
        $password = hash('sha256', $salt . sha1($_POST['password']));
        $query = prepare('INSERT INTO ``mods`` VALUES (NULL, :username, :password, :salt, :type, :boards)');
        $query->bindValue(':username', $_POST['username']);
        $query->bindValue(':password', $password);
        $query->bindValue(':salt', $salt);
        $query->bindValue(':type', $type);
        $query->bindValue(':boards', implode(',', $boards));
        $query->execute() or error(db_error($query));
        $userID = $pdo->lastInsertId();
        modLog('Created a new user: ' . utf8tohtml($_POST['username']) . ' <small>(#' . $userID . ')</small>');
        header('Location: ?/users', true, $config['redirect_http']);
        return;
    }
    mod_page(_('New user'), 'mod/user.html', array('new' => true, 'boards' => listBoards(), 'token' => make_secure_link_token('users/new')));
}
开发者ID:vicentil,项目名称:vichan,代码行数:47,代码来源:pages.php


示例19: LostPassword

function LostPassword($email)
{
    $objResponse = new xajaxResponse();
    $q = $GLOBALS['db']->GetRow("SELECT * FROM `" . DB_PREFIX . "_admins` WHERE `email` = ?", array($email));
    if (!$q[0]) {
        $objResponse->addScript("ShowBox('Error', 'The email address you supplied is not registered on the system', 'red', '');");
        return $objResponse;
    } else {
        $objResponse->addScript("\$('msg-red').setStyle('display', 'none');");
    }
    $validation = md5(generate_salt(20) . generate_salt(20)) . md5(generate_salt(20) . generate_salt(20));
    $query = $GLOBALS['db']->Execute("UPDATE `" . DB_PREFIX . "_admins` SET `validate` = ? WHERE `email` = ?", array($validation, $email));
    $message = "";
    $message .= "Hello " . $q['user'] . "\n";
    $message .= "You have requested to have your password reset for your SourceBans account.\n";
    $message .= "To complete this process, please click the following link.\n";
    $message .= "NOTE: If you didnt request this reset, then simply ignore this email.\n\n";
    $message .= "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "?p=lostpassword&email=" . RemoveCode($email) . "&validation=" . $validation;
    $headers = 'From: lostpwd@' . $_SERVER['HTTP_HOST'] . "\n" . 'X-Mailer: PHP/' . phpversion();
    $m = mail($email, "SourceBans Password Reset", $message, $headers);
    $objResponse->addScript("ShowBox('Check E-Mail', 'Please check your email inbox (and spam) for a link which will help you reset your password.', 'blue', '');");
    return $objResponse;
}
开发者ID:CodingDK,项目名称:SourceBans-Fork,代码行数:23,代码来源:sb-callback.php


示例20: password_encrypt

function password_encrypt($password)
{
    /* specify $blowfish encryption with $cost of 10 */
    $hash_format = "\$2y\$10\$";
    /* set salt length */
    $salt_length = 22;
    $salt = generate_salt($salt_length);
    $format_and_salt = $hash_format . $salt;
    $hash = crypt($password, $format_and_salt);
    return $hash;
}
开发者ID:johnthekline,项目名称:jed-web_php,代码行数:11,代码来源:functions.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP generate_sitemap函数代码示例发布时间:2022-05-15
下一篇:
PHP generate_random_string函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap