当前位置: 首页>>代码示例>>PHP>>正文


PHP Hash::salt方法代码示例

本文整理汇总了PHP中Hash::salt方法的典型用法代码示例。如果您正苦于以下问题:PHP Hash::salt方法的具体用法?PHP Hash::salt怎么用?PHP Hash::salt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Hash的用法示例。


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

示例1: createAdmin

 /**
  * createAdmin function is used to create Admin user id for MIS system.
  *
  * @return 0,1
  * @param str $name, str $username, str $password, str $privilege, int $mobile
  * @author  Harsh Vardhan Ladha
  */
 public function createAdmin($name, $username, $password, $mobile)
 {
     if (1) {
         $this->_connect();
         $name = $this->_db->real_escape_string(escape($name));
         $username = $this->_db->real_escape_string(escape($username));
         $mobile = $this->_db->real_escape_string(escape($mobile));
         $password = $this->_db->real_escape_string($password);
         $salt = Hash::salt(24);
         $hash = Hash::make($password, $salt);
         $query = "INSERT INTO admin (name,username,password,salt,privilege,mobile) VALUES ('" . $name . "','" . $username . "','" . $hash . "','" . $salt . "','admin','" . $mobile . "')";
         $result = $this->_db->query($query);
         if ($this->_db->affected_rows) {
             if ($this->_db->error == '') {
                 return 1;
             } else {
                 die($this->_db->error);
             }
         } else {
             return 0;
         }
     } else {
         return 0;
     }
 }
开发者ID:mkrdip,项目名称:Management-Information-System,代码行数:32,代码来源:Admin.php

示例2: Create

 public static function Create($Company = 1, $State = 1, $CustomRef = false)
 {
     $referenceKey = $CustomRef != false ? $CustomRef : \Hash::salt(6);
     if (count(\DB::getInstance()->table("keys")->where("key", $referenceKey)) == 0) {
         $key = \DB::getInstance()->table("keys")->insert(array("key" => $referenceKey, "companyID" => $Company, "state" => $State, "timeSent" => \Time::get()));
         return $referenceKey;
     }
     return -1;
 }
开发者ID:25564,项目名称:Resume,代码行数:9,代码来源:Key.php

示例3: process

 public function process()
 {
     $user = new Users();
     $salt = Hash::salt(32);
     //generate some tandom salt
     try {
         $user->create(array('userid' => Input::get('res-id'), 'password' => Hash::make(Input::get('res-pass'), $salt), 'salt' => $salt, 'joined' => date('Y-m-d H:i:s')));
         return 1;
     } catch (Exception $e) {
         return 0;
     }
 }
开发者ID:WWAHIDAADNAN,项目名称:JUSTAS,代码行数:12,代码来源:resister_model.php

示例4: recovery

 public function recovery($type, $email)
 {
     $type != 'username' ? $typeMessage = 'password' : ($typeMessage = 'username');
     if ($typeMessage == 'password') {
         $salt = Hash::salt(32);
         $hash = Hash::unique();
         $password = substr($hash, 1, 8);
         $password_db = Hash::make($password, $salt);
         Mail::email($email, 'Hello' . $this->data()->username . '!', '<br>
     Here is your forgotten ' . $typeMessage . ': ' . $password);
         $this->update(array('password' => $password_db, 'salt' => $salt, 'password_recover' => 1), $this->data()->id);
     } else {
         if ($typeMessage == 'username') {
             Mail::email($email, 'Hello' . Input::get('username') . '!', '<br>
       Here is your forgotten ' . $typeMessage . ': ' . $this->data()->username);
         }
     }
 }
开发者ID:TMaszko,项目名称:JagodowaPolanaOOP,代码行数:18,代码来源:User.php

示例5: validateInput

 public function validateInput($Input = array())
 {
     $validater = new \Validation();
     if (\Token::check($Input["token"])) {
         $valid = $validater->Validate($_POST, array('Username' => array('required' => true, 'min' => 3, 'max' => 35, 'unique' => 'Users'), 'Password' => array('required' => true, 'min' => 5, 'differs' => 'Username'), 'Password2' => array('required' => true, 'matches' => 'Password')));
         if ($valid === true) {
             //Register the User
             $salt = \Hash::salt();
             $hashed = \Hash::make($Input["Password"], $salt);
             $this->User = new \User();
             try {
                 $newUser = $this->User->Create(array('Username' => escape($Input["Username"]), 'Password' => $hashed, 'Salt' => $salt));
                 $this->Registered = $newUser;
             } catch (\Exception $e) {
                 $this->Errors = array($e->getMessage());
             }
         } else {
             $this->Errors = $valid;
         }
     }
 }
开发者ID:25564,项目名称:Resume,代码行数:21,代码来源:register.php

示例6: index

 public function index()
 {
     $user1 = new User();
     if ($user1->isLoggedIn()) {
         //would you like to register a new user
     } else {
         if (Input::exists()) {
             if (Token::check(Input::get('token'))) {
                 $validate = new Validation();
                 $validate->check($_POST, array('username' => array('min' => 2, 'max' => 20, 'required' => true, 'unique' => true), 'name' => array('min' => 2, 'max' => 50, 'required' => true), 'sirname' => array('min' => 2, 'max' => 50, 'required' => true), 'email' => array('min' => 5, 'max' => 64, 'email' => true, 'required' => true, 'unique' => true), 'date_of_birth' => array('min' => 6, 'max' => 10, 'date' => true, 'required' => true), 'password' => array('min' => 6, 'required' => true), 'password_again' => array('min' => 6, 'matches' => 'password', 'required' => true)));
                 if ($validate->passed()) {
                     $user = new User();
                     $salt = Hash::salt(32);
                     $date_of_birth = new Date(Input::get('date_of_birth'));
                     try {
                         $user->create(array('username' => Input::get('username'), 'name' => Input::get('name'), 'sirname' => Input::get('sirname'), 'email' => Input::get('email'), 'dateofbirth' => $date_of_birth->format('Y-m-d H:i:s'), 'password' => Hash::make(Input::get('password'), $salt), 'salt' => $salt, 'joined' => date('Y-m-d H:i:s'), 'group' => 1));
                         Session::flash('success', 'You have been registered');
                         Redirect::to('home');
                     } catch (Exception $e) {
                         die($e->getMessage());
                     }
                 } else {
                     $error_string = '';
                     //there were errors
                     //Create a file that prints errors
                     foreach ($validate->errors() as $error) {
                         $error_string .= $error . '<br>';
                     }
                     $this->view('register/failed', ['loggedIn' => 0, 'page_name' => 'Login Failed', 'errors' => $error_string]);
                 }
             }
         } else {
             //display form page
             $this->view('register/register', ['register' => true, 'page_name' => 'Register', 'loggedIn' => 0]);
         }
     }
 }
开发者ID:armourjami,项目名称:armourtake,代码行数:37,代码来源:register.php

示例7: array

if ($type == 'log') {
    $info = array('passed' => false, 'content' => '');
    $validation = $validate->check($_POST, array('email' => array('required' => true), 'password' => array('required' => true)));
    if ($validation->passed()) {
        if ($validation->login_correct()) {
            $info['passed'] = true;
            //$info ['content']=Alert::correct_signup();
        } else {
            $info['content'] = Alert::return_error_div($validation->returnErrors());
        }
    } else {
        $info['content'] = Alert::return_error_div($validation->returnErrors());
    }
    echo $info['content'];
    // echo php_encode($info);
} else {
    if ($type == 'sign') {
        $validation = $validate->check($_POST, array('first_name' => array('required' => true), 'last_name' => array('required' => true), 'email' => array('required' => true, 'unique' => 'email', 'format' => 'email'), 'password' => array('required' => true, 'min' => 6)));
        //connect to database if there are no errors
        if ($validation->passed()) {
            $instance = DB::getInstance();
            $salt = Hash::salt(10);
            $hashed_password = Hash::make($_POST['password'], $salt);
            $instance->query('INSERT INTO user (email , password , salt , first_name , last_name ) VALUES (? , ? , ? , ? , ? )', array($_POST['email'], $hashed_password, $salt, $_POST['first_name'], $_POST['last_name']));
            Alert::correct('You have successfully entered the data. Please check your e-mail to complete the sign-up.');
            //send email functionality will come here
        } else {
            Alert::return_error_div($validation->returnErrors());
        }
    }
}
开发者ID:JoeWeate,项目名称:Code-Kids,代码行数:31,代码来源:LoginController.php

示例8: header

 if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
     header("Location:" . RESOURCE_PATH_DIY . "login?error=Invalid email.");
 }
 $_POST['contact_no'] = $_POST['country_code'] . $_POST['contact_no'];
 unset($_POST['country_code']);
 $_POST['dob'] = date("Y-m-d H:i:s", strtotime($_POST['dob']));
 $client = new Client();
 try {
     $data = $client->register($_POST);
 } catch (Exception $e) {
     /*return with exception */
     header("Location:" . RESOURCE_PATH_DIY . "login?error=" . $e->getMessage());
     exit;
 }
 $_SESSION['client'] = $data;
 $access_token = Hash::get($_SESSION['client']['client_id'], Hash::salt(10) . time());
 Logger::logPlobizUser($data['client_id'], $access_token, 'N/A', uniqid(), 'WEB', 1);
 $_SESSION['client']['access_token'] = $access_token;
 /*generate verification link 
  * 26-03-15 :: time() added to make unique everytime
  * */
 $verify = Hash::get($data['email'], 'verify_email' . time());
 $crud = CRUD::getInstance();
 $crud->insert("client_reset_tokens", array('client_id' => $data['client_id'], 'type' => 'email', 'hash' => $verify));
 $mail = new Mail();
 $vlink = RESOURCE_PATH . "handlers/verify-client.php?verify=" . $verify;
 /*email verification link */
 $mail->emailVerificationMail(array(array('name' => $data['name'], 'email' => $data['email'])), $vlink);
 // 	03-07-15 : redirect to pending redirectto url
 $redirectto = isset($_SESSION['redirectto']) && $_SESSION['redirectto'] != '' ? $_SESSION['redirectto'] : RESOURCE_PATH_DIY . "dashboard";
 $_SESSION['redirectto'] = '';
开发者ID:kirannaikdanavath,项目名称:fanci,代码行数:31,代码来源:register-handler.php

示例9: User

 */
require_once 'core/init.php';
$user = new User();
if (!$user->isLoggedIn()) {
    Redirect::to('index.php');
}
if (Input::exists()) {
    if (Token::check(Input::get('token'))) {
        $validate = new Validate();
        $validation = $validate->check($_POST, array('current_password' => array('required' => true, 'min' => 6), 'new_password' => array('required' => true, 'min' => 6), 'new_password_again' => array('required' => true, 'min' => 6, 'matches' => 'new_password')));
        if ($validate->passed()) {
            if (Hash::make(Input::get('current_password'), $user->data()->salt) !== $user->data()->password) {
                Session::flash('error', 'Your current password is incorrect.');
                Redirect::to('changepassword.php');
            } else {
                $salt = Hash::salt(32);
                $user->update(array('password' => Hash::make(Input::get('new_password'), $salt), 'salt' => $salt));
                Session::flash('success', 'Your password has been changed!');
                Redirect::to('index.php');
            }
        } else {
            foreach ($validate->errors() as $error) {
                echo $error, '<br>';
            }
        }
    }
}
?>
<!DOCTYPE html>
<html>
开发者ID:TalehFarzaliey,项目名称:PHP-OOP-User-System-with-Bootstrap-Material-Design,代码行数:30,代码来源:changepassword.php

示例10: error_reporting

<?php

require_once 'core/init.php';
error_reporting(E_ALL & ~E_NOTICE);
if (Input::exists() && Input::get('submit') === "register") {
    if (Token::check(Input::get('token'))) {
        $val = new Validation();
        $directives = array("username" => array("rules" => "required|max_length-20|min_length-5|unique-users.username", "placeholder" => "Username"), "name" => array("rules" => "required|max_length-15|min_length-5", "placeholder" => "Your name"), "password" => array("rules" => "required|max_length-20|min_length-5", "placeholder" => "Password"), "password_2" => array("rules" => "required|match-password", "placeholder" => "Repeating password", "custom_msg" => "Password don't match in two fields"));
        if ($val->validate($_POST, $directives)) {
            $user = new User();
            $salt = Hash::salt('32');
            try {
                $user->create(array('username' => Input::get('username'), 'password' => Hash::make(Input::get('password'), $salt), 'salt' => $salt, 'name' => Input::get('name'), 'joined' => date('Y-m-d H:i:s'), 'user_group' => 1));
                Session::flash('success', 'you have registered successfully!');
                Redirect::to('index.php');
            } catch (Exception $e) {
                die($e->getMessage());
            }
        } else {
            echo $val->errors_html;
        }
    } else {
        echo "cross site request forgery failed";
    }
}
?>
<!DOCTYPE html>
<html>
	<head>
		<title>Register</title>
	</head>
开发者ID:shaheen13,项目名称:origin,代码行数:31,代码来源:register.php

示例11:

<?php

require_once 'core/init.php';
$offset = 0;
$name = "";
$surname = "";
$phone = "";
$mail = "";
$password = "";
$passwordAgain = "";
if (Input::exists()) {
    $salt = Hash::salt(20);
    if (!empty(Input::get('name'))) {
        $name = Input::get('name');
    }
    if (!empty(Input::get('surname'))) {
        $surname = Input::get('surname');
    }
    if (!empty(Input::get('mail'))) {
        $mail = Input::get('mail');
    }
    if (!empty(Input::get('password'))) {
        $password = Input::get('password');
    }
    if (!empty(Input::get('password_again'))) {
        $passwordAgain = Input::get('password_again');
    }
    if (!empty(Input::get('phone'))) {
        $phone = Input::get('phone');
    }
    $remember = Input::get('remember') === 'on' ? true : false;
开发者ID:Heissenbergg,项目名称:bhMakers,代码行数:31,代码来源:register.php

示例12: Validate

<?php

require_once 'core/init.php';
if (Input::exists()) {
    if (Token::check(Input::get('token'))) {
        $validate = new Validate();
        $validation = $validate->check($_POST, array('username' => array('required' => TRUE, 'min' => 2, 'max' => 20, 'unique' => 'users'), 'password' => array('required' => TRUE, 'min' => 6), 'password_again' => array('required' => TRUE, 'matches' => 'password'), 'name' => array('required' => TRUE, 'min' => 2, 'max' => 50)));
        if ($validation->passed()) {
            //Register User
            $user = new User();
            $salt = Hash::salt(30);
            try {
                $user->create(array('username' => Input::get('username'), 'password' => Hash::make(Input::get('password'), $salt), 'salt' => $salt, 'name' => Input::get('name'), 'joined' => date('Y-m-d H:i:s'), 'group' => 1));
                Session::flash('home', 'You have been registered and can now log in.');
                Redirect::to(404);
            } catch (Exception $exc) {
                // catch exception
                die($exc->getMessage());
            }
        } else {
            // Output Errors
            foreach ($validation->errors() as $error) {
                echo $error . "<br/>";
            }
        }
    }
}
?>

<form action="" method="POST" autocomplete="off">
    <div class="field">
开发者ID:muhdrazi,项目名称:OOP_login4,代码行数:31,代码来源:register.php

示例13: change_password

 public function change_password()
 {
     $user = new User();
     if (!$user->isLoggedIn()) {
         Redirect::to('home');
     }
     if (Input::exists()) {
         if (Token::check(Input::get('token'))) {
             $validate = new Validation();
             $validation = $validate->check($_POST, array('password_current' => array('required' => true, 'min' => 6), 'password_new' => array('required' => true, 'min' => 6), 'password_new_again' => array('required' => true, 'min' => 6, 'matches' => 'password_new')));
             if ($validation->passed()) {
                 if (Hash::make(Input::get('password_current'), $user->data()->salt) !== $user->data()->password) {
                     //view page error for incorrect password
                 } else {
                     $salt = Hash::salt(32);
                     $user->update(array('password' => Hash::make(Input::get('password_new'), $salt), 'salt' => $salt));
                     Session::flash('account', 'Your password has been changed');
                     Redirect::to('account');
                 }
             } else {
                 $error_string = '';
                 foreach ($validation->errors() as $error) {
                     $error_string .= $error . '<br>';
                 }
                 $this->view('account/change_password', ['register' => true, 'loggedIn' => 1, ['errors' => $error_string], 'name' => $user->data()->name, 'page_name' => 'Change user password', 'flash' => Session::flash('account')]);
             }
         }
     } else {
         $this->view('account/change_password', ['register' => true, 'loggedIn' => 1, 'name' => $user->data()->name, 'page_name' => 'Change user password', 'flash' => Session::flash('account')]);
     }
 }
开发者ID:armourjami,项目名称:armourtake,代码行数:31,代码来源:account.php

示例14: Change_Password

 public function Change_Password($password)
 {
     $user_id = $this->data()->ID;
     $salt = Hash::salt(32);
     if (!$this->_db->update('users', $user_id, array('Password' => Hash::make($password, $salt), 'salt' => $salt), 'ID')) {
         throw new Exception("Couldn't update password");
     }
     return true;
 }
开发者ID:Jaironlanda,项目名称:Hostel-Management-System,代码行数:9,代码来源:User.php

示例15: User

        <?php 
require_once 'core/init.php';
$user = new User();
if (!$user->isLoggedIn()) {
    Session::flash('home', "danger # Неоторизиран достъп, моля влезте в системата.");
    Redirect::to('login.php');
}
if (Input::exists()) {
    if (Token::check(Input::get('token'))) {
        $length = strlen(escape(Input::get('password_new')));
        if ($length >= 6) {
            if (Input::get('password_new') === Input::get('password_new_again')) {
                if (Hash::make(Input::get('password_current'), $user->data()->salt) !== $user->data()->password) {
                    Session::flash('home', 'danger # Въвели сте грешна текуща парола.');
                } else {
                    $salt = Hash::salt(Input::get('password_new'));
                    $user->update(array('password' => Hash::make(Input::get('password_new'), $salt), 'salt' => $salt));
                    Session::flash('home', 'success # Успешно променихте данните си.');
                    Redirect::to('profile.php');
                }
            } else {
                Session::flash('home', 'danger # Новата парола и нейното повторение не съвпадат.');
            }
        } else {
            Session::flash('home', 'danger # Новата парола трябва да е с дължина поне 6 символа.');
        }
    }
}
?>
        <div class="container">
            <div class="page-header">
开发者ID:xristiqn98,项目名称:DeliverIT,代码行数:31,代码来源:update.php


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