本文整理汇总了PHP中Illuminate\Hashing\BcryptHasher::make方法的典型用法代码示例。如果您正苦于以下问题:PHP BcryptHasher::make方法的具体用法?PHP BcryptHasher::make怎么用?PHP BcryptHasher::make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Hashing\BcryptHasher
的用法示例。
在下文中一共展示了BcryptHasher::make方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Generate captcha text
*
* @return string
*/
protected function generate()
{
$characters = str_split($this->characters);
$bag = '';
for ($i = 0; $i < $this->length; $i++) {
$bag .= $characters[rand(0, count($characters) - 1)];
}
$this->session->put('captcha', ['sensitive' => $this->sensitive, 'key' => $this->hasher->make($this->sensitive ? $bag : $this->str->lower($bag))]);
return $bag;
}
示例2: updateSettings
public function updateSettings(Request $request, Hash $hash)
{
$user = $request->user();
$rules = ['old_password' => 'required|min:8', 'password' => 'required|confirmed|min:8'];
$validator = app('validation')->make($request->all(), $rules);
if ($validator->fails()) {
$request->session->add(['errors' => $validator->errors()->all()]);
return app('twig')->render('user/settings.htm', ['oldInputs' => $request->all()]);
}
if (!$hash->check($request->input('old_password'), $user->password)) {
$request->session->add(['errors' => ['Old password incorrect.']]);
return app('twig')->render('user/settings.htm', ['oldInputs' => $request->all()]);
}
$user->password = $hash->make($request->input('old_password'));
$user->save();
$request->session->add(['success' => 'settings updated successfuly.']);
return app('twig')->render('user/settings.htm');
}
示例3: generate
/**
*
* @return string
*/
protected function generate()
{
$characters = str_split($this->characters);
$bag = '';
for ($i = 0; $i < $this->length; $i++) {
$bag .= $characters[rand(0, count($characters) - 1)];
}
if (!$this->sensitive) {
$bag = $this->str->lower($bag);
}
if ($this->formId) {
//Log::info('$this->formId: ' . $this->formId . ' = ' . $bag);
$this->session->put('captcha_' . $this->formId, $this->hasher->make($bag));
//Log::info('$this->formId: ' . $this->formId . ' = ' . $this->session->get('captcha_' . $this->formId));
} else {
$this->session->put('captcha', $this->hasher->make($bag));
}
return $bag;
}
示例4: make
/**
* Hash the given value.
*
* @param string $value
* @param array $options
* @return string
* @throws \RuntimeException
* @static
*/
public static function make($value, $options = array())
{
return \Illuminate\Hashing\BcryptHasher::make($value, $options);
}
示例5: hashHashable
/**
* Hash any hashable attributes
*
* @return null
*/
private function hashHashable()
{
$hasher = new BcryptHasher();
$filtered = array_filter($this->attributes);
foreach ($filtered as $key => $value) {
if (in_array($key, $this->hashable) && $value != $this->getOriginal($key)) {
$this->attributes[$key] = $hasher->make($value);
}
}
}
示例6: hash
/**
* Create a new HashedPassword
*
* @param Password $password
* @return HashedPassword
*/
public function hash(Password $password)
{
return new HashedPassword($this->hasher->make($password->toString()));
}
示例7: hash
/**
* Create a new HashedPassword
*
* @param Password $password
* @return HashedPassword
*/
public function hash(Password $password)
{
return new HashedPassword($this->hasher->make((string) $password));
}
示例8: getAuthPassword
public function getAuthPassword()
{
$hasher = new BcryptHasher();
return $hasher->make($this->password);
}
示例9: changePassword
public function changePassword()
{
$adminId = Input::get("adminId");
$username = Input::get("username");
$oldPassword = Input::get("oldPassword");
$newPassword = Input::get("newPassword");
$newPasswordConfirm = Input::get("newPasswordConfirm");
$hasher = new BcryptHasher();
if (Auth::attempt(array('username' => $username, 'password' => $oldPassword))) {
$result = Admin::where("admin_id", "=", $adminId)->update(["password" => $hasher->make($newPassword)]);
if ($result == 0) {
return Response::json(array('errCode' => 1, 'errMsg' => "[修改失败]数据库错误"));
}
} else {
return Response::json(array('errCode' => 1, 'errMsg' => "[修改失败]原密码错误"));
}
return Response::json(array('errCode' => 0));
}
示例10: postPassword
/**
* @param Request $request
* @param BcryptHasher $hasher
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postPassword(Request $request, BcryptHasher $hasher)
{
$this->failedValidationRedirect = route('account.password');
$this->validate($request, ['password1' => 'required|min:6', 'password' => 'required']);
if ($this->guard->getProvider()->validateCredentials($this->guard->user(), $request->only('password'))) {
// Don't save the password in plaintext!
ConfirmationManager::send('password', $this->guard->user(), 'account.password.confirm', $hasher->make($request->get('password1')));
return redirect()->route('account.profile')->withSuccess(trans('account.confirm'));
}
return redirect()->route('account.password')->withInput($request->only('password1'))->withErrors(['password1' => trans('member.invalidCredentials')]);
}