本文整理汇总了PHP中Crypt::hash方法的典型用法代码示例。如果您正苦于以下问题:PHP Crypt::hash方法的具体用法?PHP Crypt::hash怎么用?PHP Crypt::hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crypt
的用法示例。
在下文中一共展示了Crypt::hash方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postSignUp
public function postSignUp()
{
$data = \Data::post()->all();
$UserDataModel = new \App\data_model\User($data);
if (!$UserDataModel->verify()) {
\Session::setFlash('signup-data', $UserDataModel->getData());
\Session::setFlash('signup-errors', $UserDataModel->getErrors());
} else {
$UserRecord = new \App\record\User($data);
$UserRecord['password'] = \Crypt::hash($UserRecord['password']);
$UserRecord['created_on_date'] = array('raw' => 'NOW()');
$UserRecord->insert();
\App::with('User')->sendActivationEmail($UserRecord['id']);
\Session::setFlash('signup-success', 1);
}
//el
\View::redirect('/signup');
}
示例2: postEditPassword
public function postEditPassword()
{
$data = \Data::post(array('password_current', 'password', 'password_verify'));
$UserDataModel = new \App\data_model\User($data);
$current_password = \App::with('User')->User->select('password')->where('id=?', \App::with('User')->userId())->first()['password'];
if (\Crypt::hash($data['password_current']) != $current_password) {
\Session::setFlash('edit-password-errors', array('password_current' => 'That wasn\'t your current password'));
} else {
if (!$UserDataModel->verifySetData()) {
\Session::setFlash('edit-password-errors', $UserDataModel->getErrors());
} else {
\App::with('User')->changePassword($UserDataModel['password']);
\Session::setFlash('edit-success', 'Password Updated!');
}
}
//el
\View::redirect('/user/edit');
}
示例3: setPassword
/**
* Sets the password for the user
*
* @param string $password
* @param string $algorithm
* @param array $options [optional]
*/
public function setPassword($password, $algorithm = PasswordFile::ALG_MD5, array $options = null)
{
$this->hash = Crypt::hash($password, $algorithm, $options);
}
示例4: createAuthCode
public function createAuthCode()
{
// Save random auth code in users meta data
$authcode = Crypt::hash("random:authcode:" . DateManager::now() . ":" . rand());
Meta::remove("user", $this->id, "authcode");
Meta::save("user", $this->id, "authcode", Crypt::createHash($authcode));
}
示例5: changePassword
/**
* Change the current users password.
*
* @param string $password The new password.
* @param int $user_id The id of the user.
*
* @return boolean
*/
public function changePassword($password, $user_id = null)
{
if ($user_id === null) {
$user_id = $this->userId();
}
//if
return $this->User->update(array('password' => \Crypt::hash($password)))->where('id=?', $user_id)->finalize();
}