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

PHP generateSalt函数代码示例

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

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



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

示例1: addNewUser

function addNewUser($dbHandler, $username, $password, $permission)
{
    $thisUserPasswordSalt = generateSalt(5);
    $thisUserPasswordHash = md5($password . $thisUserPasswordSalt);
    // create table and insert first root user
    $dbHandler->query("INSERT INTO users (username, salt, password, permissions) VALUES('{$username}', '{$thisUserPasswordSalt}', '{$thisUserPasswordHash}', {$permission});");
}
开发者ID:htruong,项目名称:geniemon,代码行数:7,代码来源:utils.php


示例2: register

 /**
  * Register Admin
  */
 function register()
 {
     initiateSession();
     $this->set("title", "Sevasetu | New Admin");
     if (isset($_SESSION['admin_hash'])) {
         header("LOCATION: /admins/dashboard");
     }
     $name = sqlSafe($_POST['name']);
     $username = sqlSafe($_POST['username']);
     $password = sqlSafe($_POST['password']);
     $password2 = sqlSafe($_POST['password2']);
     $salt = generateSalt();
     $email = sqlSafe($_POST['email']);
     if ($password === $password2) {
         $password = generateHash($password . $salt);
     } else {
         $this->set("message", "Password doesn't match");
         return false;
     }
     if ($this->Admin->insertAdmin($name, $username, $email, $salt, $password) == true) {
         $this->set("message", "Administrator Registered.");
     } else {
         $this->set("message", "Unable to register admin");
     }
 }
开发者ID:h4xr,项目名称:Sevasetu,代码行数:28,代码来源:adminscontroller.php


示例3: registreerNieuweUser

function registreerNieuweUser($login, $pasw)
{
    $_SESSION["msg"] = "Registratie niet gelukt. Probeer later opnieuw.";
    //default message
    //controleren of de login reeds gebruikt is....
    $connection = new W_DatabaseHelper("cms");
    $querystring = "SELECT * \n\t\t\t\t\t\t FROM users \n\t\t\t\t\t\t WHERE naam LIKE :login \n\t\t\t\t\t\t";
    $bindValues = [":login" => $login];
    $resultset = $connection->query($querystring, $bindValues);
    //$resultset = $connection->query($querystring);
    //var_dump($resultset);
    if (sizeof($resultset) > 0) {
        $_SESSION["msg"] = "Deze naam is reeds in gebruik. Gelieve een andere login te kiezen.";
    } else {
        $querystring = "INSERT INTO users(naam, paswoord, salt) \n\t\t\t\t\t\t\tVALUES (:login, :pasw, :newsalt) \n\t\t\t\t\t\t\t";
        ///// SECURITY voor paswoord...
        //salt aanmaken
        $newsalt = generateSalt();
        //parameter 5 in onderstaande lijn betekent dat we kiezen voor algoritme SHA256...
        $pasw = hash("sha256", $pasw . $newsalt);
        var_dump($pasw);
        $bindValues = [":login" => $login, ":pasw" => $pasw, ":newsalt" => $newsalt];
        $resultset = $connection->query($querystring, $bindValues);
        $validatedUser = checklogin($login, $pasw);
        $_SESSION["msg"] = "Proficiat met uw registratie. U bent meteen ook ingelogd met uw nieuwe login en paswoord.";
        /// get the new user's userid...
        $querystring = "SELECT userid FROM users\n\t\t\t\t\t\t\tWHERE naam LIKE :login \n\t\t\t\t\t\t\tAND paswoord LIKE :pasw \n\t\t\t\t\t\t\tAND salt LIKE :newsalt\n\t\t\t\t\t\t\t";
        $bindValues = [":login" => $login, ":pasw" => $pasw, ":newsalt" => $newsalt];
        $resultset = $connection->query($querystring, $bindValues);
        var_dump($resultset);
        $_SESSION["user"] = $resultset[0];
        $_SESSION["username"] = $login;
    }
    //return $resultmessage;
}
开发者ID:WVits,项目名称:web-backend-oplossingen,代码行数:35,代码来源:registratie-proces.php


示例4: createAdmin

 public function createAdmin($username, $email, $password)
 {
     if ($this->input->is_cli_request()) {
         $saltkey = generateSalt();
         $salt_password = crypt($password, $saltkey);
         $this->setup_model->generateAdmin($username, $saltkey, $salt_password, $email);
     }
 }
开发者ID:jackysnguyen,项目名称:khohangangular,代码行数:8,代码来源:setup.php


示例5: adduser

function adduser($username, $password, $level, $email = "", $realname = "", $can_modify_passwd = '1', $description = "")
{
    if (!user_exists($username)) {
        $encrypted = crypt($password, '$1$' . generateSalt(8) . '$');
        return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description), 'users');
    } else {
        return FALSE;
    }
}
开发者ID:RomanBogachev,项目名称:observium,代码行数:9,代码来源:mysql.inc.php


示例6: hashUserID

function hashUserID($ID)
{
    $salt1 = generateSalt($ID);
    // reverse the $ID and generate another salt
    $salt2 = generateSalt(strrev((string) $ID));
    $salted = $salt1 . $ID . $salt2;
    $hashUserID = hash("sha256", $salted);
    //    $hashUserID = $ID;
    return $hashUserID;
}
开发者ID:anzhao,项目名称:CLAS,代码行数:10,代码来源:auth.inc.php


示例7: passwordEncrypt

function passwordEncrypt($password)
{
    // use Blowfish with a "cost" of 10
    $hash_format = "\$2y\$10\$";
    $salt_length = 22;
    $salt = generateSalt($salt_length);
    $format_and_salt - $hash_format . $salt;
    $hash = crypt($password, $format_and_salt);
    return $hash;
}
开发者ID:dianaruth,项目名称:sensemysoil,代码行数:10,代码来源:functions.php


示例8: testGenerateSalt

 public function testGenerateSalt()
 {
     // each salt is unique, so we test length of salt generated
     $this->assertEquals(22, strlen(generateSalt(22)));
     $this->assertEquals(1, strlen(generateSalt(1)));
     $this->assertEquals(0, strlen(generateSalt(0)));
     $this->assertEquals(40, strlen(generateSalt(40)));
     // test that no two salts are identical
     $this->assertFalse(generateSalt(22) == generateSalt(22));
     $this->assertFalse(generateSalt(4) == generateSalt(4));
     // salts of length 0 are identical
     $this->assertEquals(generateSalt(0), generateSalt(0));
 }
开发者ID:dianaruth,项目名称:sensemysoil,代码行数:13,代码来源:unittest.php


示例9: userIsLoggedIn

/**
 * This function compares the submitted email & password to those in the user
 * table for a match and starts a session with ['loggedIn'} = TRUE if found.
 * @return boolean
 */
function userIsLoggedIn()
{
    $salt = generateSalt($_POST['email']);
    $password = generateHash($salt, $_POST['password']);
    if (databaseContainsUser($_POST['email'], $password)) {
        $_SESSION['loggedIn'] = TRUE;
        $_SESSION['email'] = $_POST['email'];
        $_SESSION['password'] = $password;
        return TRUE;
    } else {
        unset($_SESSION['loggedIn']);
        unset($_SESSION['email']);
        unset($_SESSION['password']);
        return FALSE;
    }
}
开发者ID:lintonrentfro,项目名称:simpleconvention,代码行数:21,代码来源:access.inc.php


示例10: register

 /**
  * Sets the contents for the processing of user registration form
  */
 function register()
 {
     initiateSession();
     $this->set("title", "IEEE NIEC | New User Registration");
     if (isset($_SESSION['user_id'])) {
         header("LOCATION: /indexs/home");
     }
     $name = sqlSafe($_POST['name']);
     $username = sqlSafe($_POST['username']);
     $password = sqlSafe($_POST['password']);
     $password2 = sqlSafe($_POST['password2']);
     $salt = generateSalt();
     $email = sqlSafe($_POST['email']);
     $dor = date("Y-m-d H:i:s");
     $dob = sqlSafe($_POST['dob']);
     $profilepicPath = ROOT . DS . 'public' . DS . 'uploads' . DS . 'dp' . DS . 'default.jpg';
     if ($password === $password2) {
         $password = generateHash($password . $salt);
     } else {
         $this->set("message", "Password doesn't match");
     }
     $profilepic = new Image($_FILES['profile_picture']);
     $profilepic->setUploadPath(ROOT . DS . 'public' . DS . 'uploads' . DS . 'dp');
     if ($profilepic->validate() == false) {
         $this->set("message", "Unsupported Image Format for profile picture. Try again.");
     } else {
         if ($profilepic->moveUploadedImage() == true) {
             $profilepicPath = $profilepic->getUploadLocation();
             $profilepic = null;
         } else {
             $this->set("message", "Error uploading profile picture. Try again after some time.");
         }
     }
     if ($this->User->insertUser($name, $username, $password, $salt, $email, $dob, $dor, $profilepicPath) == -1) {
         $this->set("message", "There was some error processing your request. Try again later.");
     } else {
         $this->sendActivationMail($username);
         $this->set("message", "Registration Successful. Please check your mail to activate your account.");
     }
 }
开发者ID:h4xr,项目名称:Sevasetu,代码行数:43,代码来源:userscontroller.php


示例11: recoverSendMail

function recoverSendMail($db, $sEmail)
{
    global $config;
    $row = getUserFromEmail($db, $sEmail);
    if (!$row) {
        echo json_encode(array("success" => false));
        return;
    }
    $sRecoverCode = generateSalt();
    $query = "UPDATE `user` SET `recoverCode` = ? WHERE `ID` = ?";
    $stmt = $db->prepare($query);
    $stmt->execute(array($sRecoverCode, $row->ID));
    if ($sEmail !== "") {
        $link = $config->teacherInterface->sCoordinatorFolder . "/recover.php?action=recover&email=" . urlencode($sEmail) . "&recoverCode=" . urlencode($sRecoverCode);
        $sBody = "Bonjour,\r\n\r\nPour définir un nouveau mot de passe, ouvrez le lien suivant dans votre navigateur  : \r\n\r\n" . $link . "\r\n\r\nN'hésitez pas à nous contacter si vous rencontrez des difficultés.\r\n\r\nCordialement,\r\n--\r\nL'équipe du Castor Informatique";
        $sTitle = "Réinitialisation de mot de passe Coordinateur Castor Informatique";
        sendMail($sEmail, $sTitle, $sBody, $config->email->sEmailSender);
        //$params = array('recoverCode' => $recoverCode, 'email' => $email);
        //http_post("eval01.france-ioi.org", 80, "/castor/sendMail2.php", $params);
    }
    echo json_encode(array("success" => true));
}
开发者ID:BebrasTeam,项目名称:BebrasContestServer,代码行数:22,代码来源:recover.php


示例12: login

/**
 * @param $username
 * @param $userpass
 * @return bool|object
 * Login.
 */
function login($username, $userpass)
{
    if ($username == "" || $userpass == "") {
        return false;
    }
    $salt = "";
    $sql = "SELECT Salt, UserID FROM tbl_users WHERE Email = " . convertForInsert($username);
    $mysqli = new mysqli(Database::dbserver, Database::dbuser, Database::dbpass, Database::dbname);
    $rs = $mysqli->query($sql);
    while ($row = $rs->fetch_assoc()) {
        $userid = $row['UserID'];
        $salt = $row['Salt'] == "" ? generateSalt($userid) : $row['Salt'];
    }
    $salted = encryptPassword($userpass, $salt);
    $rs->free();
    $mysqli->close();
    $sql = "SELECT UserID, FirstName FROM tbl_users WHERE Email = " . convertForInsert($username) . " AND Password = " . convertForInsert($salted);
    $mysqli = new mysqli(Database::dbserver, Database::dbuser, Database::dbpass, Database::dbname);
    $rs = $mysqli->query($sql);
    if ($rs->num_rows < 1) {
        //we don't have this user
        return false;
    } else {
        while ($row = $rs->fetch_assoc()) {
            $data = array("success" => true, "usertoken" => generateToken($row['UserID']), "userfirstname" => $row['FirstName']);
            return json_encode($data);
        }
        //return true;
    }
}
开发者ID:misumoo,项目名称:timesheet,代码行数:36,代码来源:_handle.php


示例13: createUsers

function createUsers($IDs, $role, $dbConn, $isIDsHashed = false, $firstName = null, $lastName = null)
{
    global $AES_key, $DEPLOYMENT_NAME;
    $userIDs = null;
    // deal with null firstname & lastname, convert to "NULL" for SQL
    $firstName = $firstName == null ? "NULL" : $firstName;
    $lastName = $lastName == null ? "NULL" : $lastName;
    // convert to array
    if (!is_array($IDs)) {
        $IDs = (array) $IDs;
    }
    foreach ($IDs as $ID) {
        //TODO: add DB contraint unique per user
        // This function can be called either with a pre-hashed ID or an unhashed userID
        // situations for calling with a pre-hashed ID include updating a class list, or
        // giving existing users permissions (student or instructor) to a new class
        $isIDsHashed ? $hashUserID = $ID : ($hashUserID = hashUserID($ID));
        // Check to see if the user already existed
        $query = "SELECT id FROM users WHERE hash_user_id LIKE '{$hashUserID}'";
        $result = mysql_query($query, $dbConn);
        $resultText = $result == false ? "<div style=\"color:red;\">failed, error: " . mysql_error($dbConn) . "</div>" : "<div style=\"color:green;\">ok, retVal: " . mysql_result($result, 0) . "</div>";
        print "<br/>Debug Info: {$query} - Result: {$resultText}<br/>";
        // get the OVAL userID of the last insert of this hashed university ID
        if (1 == mysql_num_rows($result)) {
            $userID = mysql_result($result, 0);
        } else {
            $saltedID = $ID . generateSalt($ID);
            if ($DEPLOYMENT_NAME === "dev") {
                $query = "INSERT INTO users VALUES (NULL, '{$hashUserID}', AES_ENCRYPT('{$saltedID}', '{$AES_key}'), '{$firstName}', '{$lastName}', {$role}, NULL)";
            } else {
                $query = "INSERT INTO users VALUES (NULL, '{$hashUserID}', '', '{$firstName}', '{$lastName}', {$role}, NULL)";
            }
            $result = mysql_query($query, $dbConn);
            $resultText = $result == false ? "<div style=\"color:red;\">failed, error: " . mysql_error($dbConn) . "</div>" : "<div style=\"color:green;\">ok, retVal: " . mysql_result($result, 0) . "</div>";
            $query = str_replace($AES_key, "", $query);
            print "<br/>Debug Info: {$query} - Result: {$resultText}<br/>";
            // user already exists so query id
            $userID = mysql_insert_id();
        }
        //print "userID:$userID<br />";
        // collect users.id
        $userIDs[] = $userID;
    }
    return $userIDs;
}
开发者ID:abelardopardo,项目名称:oval,代码行数:45,代码来源:clas_adm.php


示例14: password_reset_by_token

function password_reset_by_token($username, $token, $password, $repeat_password)
{
    $userid = is_simplerisk_user($username);
    // Verify that the passwords match
    if ($password == $repeat_password) {
        // If the username exists
        if ($userid != 0) {
            // If the reset token is valid
            if (is_valid_reset_token($username, $token)) {
                // Open the database connection
                $db = db_open();
                // Create the new password hash
                $salt = generateSalt($username);
                $hash = generateHash($salt, $password);
                // Update the password
                $stmt = $db->prepare("UPDATE user SET password=:hash WHERE username=:username");
                $stmt->bindParam(":hash", $hash, PDO::PARAM_STR, 60);
                $stmt->bindParam(":username", $username, PDO::PARAM_STR, 20);
                $stmt->execute();
                // Close the database connection
                db_close($db);
                return true;
            }
        } else {
            return false;
        }
    } else {
        return false;
    }
}
开发者ID:google-code-backups,项目名称:simplerisk,代码行数:30,代码来源:authenticate.php


示例15: it

     if ($QR === 'NONE') {
         $mypage->leaf('p', 'Couldn\'t find a user named ' . $EscapedAccountName . '. Please check that you spelled the account name correctly.');
     } else {
         if (!$QR['UserValidated']) {
             $mypage->leaf('p', 'That user account isn\'t validated yet. If you haven\'t received your validation email, you can visit <a href="resendvalemail.php">this page</a> to re-send it (although you will need your password to do so).');
         } else {
             if ($QR['Email'] == '') {
                 $mypage->leaf('p', 'There was a problem sending the email. Either the account email address is blank, or the email could not be sent for some other reason. You might want to try again; if it still doesn\'t work, you can ask the Administrator to investigate, but be aware that the Administrator will only go so far as to check for problems with this script and with the site\'s ability to send emails, not give you access to your account.');
             } else {
                 $CharArray = 'abcdefghijklmnopqrstuvwxyz0123456789';
                 $thevstring = '';
                 for ($i = 0; $i < 20; $i++) {
                     $j = rand(0, 35);
                     $thevstring .= $CharArray[$j];
                 }
                 $encryptedthevstring = crypt($thevstring, generateSalt());
                 $QueryResult = dbquery(DBQUERY_WRITE, 'UPDATE "User" SET "ScrambleKey" = :scramblekey: WHERE "UserID" = :user:', 'scramblekey', $encryptedthevstring, 'user', $QR['UserID']);
                 $subject = 'Account Recovery Email for Brass';
                 $body = '<p>Account recovery has been requested for your account ' . $EscapedAccountName . ' for Brass. If it was not you who submitted the request, please ignore this email.</p><p>Please click on the url on the next line, or copy and paste it into your browser\'s address bar.</p><p><a href="' . SITE_ADDRESS . 'recoveraccountb.php?UserID=' . $QR['UserID'] . '&amp;VString=' . $thevstring . '">' . SITE_ADDRESS . 'recoveraccountb.php?UserID=' . $QR['UserID'] . '&amp;VString=' . $thevstring . '</a></p>' . EMAIL_FOOTER;
                 if (send_email($subject, $body, $QR['Email'], null)) {
                     $mypage->leaf('p', 'An account recovery email for ' . $EscapedAccountName . ' has been sent.');
                     $mypage->finish();
                 } else {
                     $mypage->leaf('p', 'There was a problem sending the email. Either the account email address is blank, or the email could not be sent for some other reason. You might want to try again; if it still doesn\'t work, you can ask the Administrator to investigate, but be aware that the Administrator will only go so far as to check for problems with this script and with the site\'s ability to send emails, not give you access to your account.');
                 }
             }
         }
     }
 } else {
     $EscapedAccountName = '';
     $mypage->leaf('p', 'This page may be used to attempt to recover access to an account for which you have forgotten the password. Use this feature if you are the owner of the account and you cannot remember your password. You will need to know your Secret Answer, and have access to your email address.');
开发者ID:hdp,项目名称:brass,代码行数:31,代码来源:recoveraccount.php


示例16: newPass

 function newPass($pass, $verify)
 {
     global $lang;
     global $db;
     $id = 0;
     $sql = "SELECT `id` FROM `teams` WHERE `id`=? AND `verification`=?";
     $stmt = $db->prepare($sql);
     $stmt->bind_param("is", $this->id, $verify);
     $stmt->bind_result($id);
     $stmt->execute();
     $stmt->store_result();
     $stmt->fetch();
     if ($stmt->num_rows != 1 || $id !== $this->id) {
         throw new Exception($lang['team'][11]);
     }
     $stmt->close();
     if (strlen($pass) < 1) {
         throw new Exception($lang['register'][3]);
     }
     $salt = generateSalt();
     $hash = hashPass($salt, $pass);
     $salt = base64_encode($salt);
     $sql = "UPDATE `teams` SET `pass`=?, `salt`=? WHERE `id`=?";
     $stmt = $db->prepare($sql);
     $stmt->bind_param("ssi", $hash, $salt, $this->id);
     $stmt->execute();
     $stmt->close();
     return true;
 }
开发者ID:zysicing,项目名称:CTFSys,代码行数:29,代码来源:team.php


示例17: print_assertation

function print_assertation($cid, $badgetext, $badgename, $descr, $userid, $email)
{
    global $badgeid, $installname, $imasroot;
    header('Content-Type: application/json');
    if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
        $urlmode = 'https://';
    } else {
        $urlmode = 'http://';
    }
    $urlbase = $urlmode . $_SERVER['HTTP_HOST'];
    $salt = generateSalt();
    $hash = 'sha256$' . hash('sha256', $email . $salt);
    $bs = substr($badgetext, 0, 7);
    if ($bs == 'http://' || $bs == 'https:/') {
        $img = $badgetext;
    } else {
        $img = "{$imasroot}/img/badge.php?text=" . urlencode($badgetext);
    }
    /*$query = "SELECT imas_courses.name AS cname, imas_users.LastName, imas_users.FirstName, imas_users.email, imas_groups.name FROM imas_courses JOIN imas_teachers ON imas_courses.id=imas_teachers.courseid ";
    	$query .= "JOIN imas_users ON imas_teachers.userid=imas_users.id LEFT JOIN imas_groups ON imas_users.groupid=imas_groups.id WHERE imas_courses.id='$cid' LIMIT 1";
    	$result = mysql_query($query) or die("Query failed : " . mysql_error());
    	if (mysql_num_rows($result)==0) {
    		$org = ' ';
    		$email = ' ';
    	} else {
    		$t = array();
    		$e = array();
    		$cname = '';
    		while ($row = mysql_fetch_row($result)) {
    			$cname = $row[0];
    			if ($row[4]==null) {
    				$t[] = $row[1].', '.$row[0];
    			} else {
    				$t[0] = $row[1].', '.$row[2] . ' ('.$row[4].')';
    			}
    			$e[] = $row[3];
    		}
    		$org = 'Course: '.$cname.'. Instructor'.((count($t)>1)?'s':'').': '.implode(', ',$t);
    		$contact = implode(', ', $e);
    	}*/
    echo <<<END
{
\t"recipient": "{$hash}",
\t"salt": "{$salt}",
\t"badge": {
\t\t"version": "0.5.0",
\t\t"name": "{$badgename}",
\t\t"image": "{$img}",
\t\t"description": "{$descr}",
\t\t"criteria": "{$imasroot}/course/verifybadge.php?badgeid={$badgeid}",
\t\t"issuer": {
\t\t\t"origin": "{$urlbase}",
\t\t\t"name": "{$installname}"
\t\t}
\t}
}\t\t
END;
    //  can't include because of FERPA :(
    // "evidence": "$imasroot/course/verifybadge.php?badgeid=$badgeid&userid=$userid",
    //
    //too long, so don't bother
    // 			"org": "$org",
    //			"email": "$contact"
}
开发者ID:ericvanboven,项目名称:IMathAS,代码行数:64,代码来源:verifybadge.php


示例18: generateSalt

<?php

/**
 * This function generates a password salt as a string of x (default = 15) characters
 * in the a-zA-Z0-9!@#$%&*? range.
 * @param $max integer The number of characters in the string
 * @return string
 * @author AfroSoft <[email protected]>
 */
function generateSalt($max = 15)
{
    $characterList = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#\$%&*?";
    $i = 0;
    $salt = "";
    while ($i < $max) {
        $salt .= $characterList[mt_rand(0, strlen($characterList) - 1)];
        $i++;
    }
    return $salt;
}
echo generateSalt();
开发者ID:CaioFlavio,项目名称:catalogapp,代码行数:21,代码来源:generate_salt.php


示例19: session_start

if ($_SERVER['REQUEST_METHOD'] == "POST") {
    session_start();
    $errorFlag = false;
    // let us know further down if there was a problem
    $passwordcorrect = false;
    $dbh = db_connect();
    // from login.php:33
    $sql = "SELECT id, \"user\", hash, salt, name FROM users WHERE \"user\" = :username";
    $sth = $dbh->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
    $sth->execute(array(":username" => $_SESSION["username"]));
    $data = $sth->fetch(PDO::FETCH_ASSOC);
    if ($data && hash("sha256", $_POST["oldpass"] . $data["salt"]) == $data["hash"]) {
        // password was correct.
        if ($_POST["newpass"] != "" && $_POST["newpass"] == $_POST["confirmpass"]) {
            // update password
            $salt = generateSalt(40);
            $hash = hash("sha256", $_POST["newpass"] . $salt);
            $sql = "UPDATE users SET (hash, salt, name) = (:hash, :salt, :name) WHERE id = :id";
            $sth = $dbh->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
            $sth->execute(array(":id" => $_SESSION["userid"], ":hash" => $hash, ":salt" => $salt, ":name" => $_POST["name"]));
            $data = $sth->fetch(PDO::FETCH_ASSOC);
        } else {
            if ($_POST["newpass"] != "" && $_POST["newpass"] != $_POST["confirmpass"]) {
                // new passwords do not match
                echo '<div class="alert alert-error">
                          <button type="button" class="close" data-dismiss="alert">&times;</button>
                          <strong>New passwords do not match.</strong> Please try again.
                        </div>';
                $errorFlag = true;
            } else {
                // just update settings
开发者ID:rechner,项目名称:taxidi-web,代码行数:31,代码来源:profile.php


示例20: array

<?php

require_once "team.php";
require_once "utility.php";
require_once "en.php";
$teams = array();
#NULL POINTER
$teams[] = array("name" => "NULLPOINTER", "members" => "Mehmet Can Demirel", "email" => "[email protected]");
$t = new Teams();
foreach ($teams as $team) {
    $pass = base64_encode(generateSalt(10));
    $t->register($team["name"], $pass, $team["email"], explode("<%#:#%>", $team["members"]));
}
开发者ID:zysicing,项目名称:CTFSys,代码行数:13,代码来源:teamsreg.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP generateSelect函数代码示例发布时间:2022-05-15
下一篇:
PHP generateRequestToken函数代码示例发布时间: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