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


PHP Hash::create方法代码示例

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


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

示例1: run

 public function run($static = false)
 {
     $form = new Form();
     $form->post('login')->val('blank')->post('password')->val('blank');
     if (!$form->submit()) {
         // Error
         $this->_error($static);
         return false;
     }
     $data = $form->fetch();
     $login = $data['login'];
     $password = Hash::create('sha256', $data['password'], PASS_HASH_KEY);
     $query = "SELECT userid, login, role FROM user WHERE login = :login AND password = :password";
     if (!($result = $this->db->select($query, array(':login' => $login, ':password' => $password)))) {
         $this->_error($static);
         return false;
     }
     Session::init();
     Session::set('userid', $result[0]['userid']);
     Session::set('login', $result[0]['login']);
     Session::set('role', $result[0]['role']);
     Session::set('loggedIn', true);
     if ($static) {
         header('location:' . URL . 'dashboard');
     }
     echo json_encode('success');
 }
开发者ID:spelgrift,项目名称:imageman,代码行数:27,代码来源:login_model.php

示例2: auth

 public function auth()
 {
     $user = new User();
     $username = $_POST['username'];
     $password = Hash::create('md5', $_POST['password'], HASH_SALT_KEY);
     $data = $user->getUser($username, $password);
     foreach ($data as $value) {
         $this->user = $value->get('nama_user');
         $this->nama = $value->get('namaPegawai');
         $this->role = $value->get('role');
         $this->bagian = $value->get('bagian');
     }
     $int = count($data);
     $this->view->error = array();
     if ($int > 0) {
         @Session::createSession();
         Session::set('loggedin', true);
         Session::set('user', $this->user);
         Session::set('nama', $this->nama);
         Session::set('role', $this->role);
         Session::set('bagian', $this->bagian);
         $log = new Log();
         $log->addLog(Session::get('user'), 'LOGIN', '');
         unset($log);
         //            header('location:../home');
         echo json_encode(array('status' => 'success'));
     } else {
         //            $this->view->error['invalid'] = 'Akun tidak ditemukan';
         //header('location:../login');
         //            $this->view->render('login/index');
         //            echo 'Akun tidak ditemukan';
         echo json_encode(array('status' => 'error', 'message' => 'Akun tidak ditemukan'));
     }
 }
开发者ID:ryderonil,项目名称:sisurip,代码行数:34,代码来源:login_controller.php

示例3: run

 public function run()
 {
     /*
      * md5 is a 32 bit hash
      */
     $statement = $this->db->prepare("SELECT id, role FROM users WHERE login = :user AND password = :pass");
     $statement->execute(array(':user' => $_POST['user'], ':pass' => Hash::create('sha256', $_POST['pass'], HASH_KEY)));
     /*
      * The Obj returned by $statement was 'Array of Arrays'
      */
     $result = $statement->fetchAll();
     //$statement returns an Array of objects
     //print_r($result);
     //echo '</br>';
     $data = $result['0'];
     //print_r($data);
     //echo '</br>role='.$data['role'];
     $count = $statement->rowCount();
     if ($count > 0) {
         //log in the user
         Session::init();
         Session::set('userid', $data['id']);
         Session::set('role', $data['role']);
         Session::set('loggedIn', true);
         header('location: ../dashboard');
     } else {
         //show an error
         header('location: ../login');
     }
 }
开发者ID:saptharsh,项目名称:Project-Management-App,代码行数:30,代码来源:login_model.php

示例4: run

 public function run()
 {
     $login = $_POST['login'];
     $password = $_POST['password'];
     /* PDO */
     $res = $this->db->prepare("SELECT userid, role FROM users WHERE\n                login = :login AND password = :password");
     $res->execute(array(':login' => $login, ':password' => Hash::create(HASH_METHOD, $password, HASH_PASSWORD_KEY)));
     //        $data = $res->fetchAll();
     $count = $res->rowCount();
     /* mysqli */
     /*$res = $this->db->prepare("select id from users
           where login = ?
           and password = MD5(?)");
       $res->bind_param("ss",$login,$password);
       $res->execute();
       $res->bind_result($ret);
       $res->fetch();*/
     $data = $res->fetch();
     if ($count > 0) {
         //login
         Session::init();
         Session::set('role', $data['role']);
         Session::set('loggedIn', true);
         Session::set('userid', $data['userid']);
         header('Location:../dashboard');
         exit;
     } else {
         //show an Error
         header('Location:../login');
         exit;
     }
     //        return $ret;
 }
开发者ID:Ristee,项目名称:mvctest3,代码行数:33,代码来源:Login_Model.php

示例5: editSave

 public function editSave($data)
 {
     $myTable = 'users';
     $postData = array('login' => $data['login'], 'password' => Hash::create('sha256', $data['password'], HASH_PASSWORD_KEY), 'role' => $data['role']);
     $where = "`id` = {$data['id']}";
     $this->db->update($myTable, $postData, $where);
 }
开发者ID:azimnorazmi,项目名称:mvc-melayu,代码行数:7,代码来源:pengguna_tanya.php

示例6: changePass

 function changePass()
 {
     Auth::handleClientLogin();
     $data['client_id'] = Session::get('client_id');
     $client_pass = $this->model->getPass();
     $client_old_pass = Hash::create('md5', $_POST['client_old_pass'], HASH_PASSWORD_KEY);
     if ($client_pass[0]['client_pass'] != $client_old_pass) {
         echo -2;
         exit;
     }
     if ($_POST['client_old_pass'] == '' || $_POST['client_pass_1'] == '' || $_POST['client_pass_2'] == "") {
         echo -1;
         exit;
     }
     if (strlen($_POST['client_pass_1']) < 6 || strlen($_POST['client_pass_2']) < 6) {
         echo 0;
         exit;
     }
     if ($_POST['client_pass_1'] != $_POST['client_pass_2']) {
         echo 1;
         exit;
     }
     $data['client_pass'] = Hash::create('md5', $_POST['client_pass_2'], HASH_PASSWORD_KEY);
     $this->model->changePass($data);
 }
开发者ID:trongloikt192,项目名称:Project_Wahanda_Alternative,代码行数:25,代码来源:clientsetting.php

示例7: testCreate

 /**
  * @covers ::__construct
  * @covers ::create
  * @covers ::set
  * @covers ::has
  * @covers ::get
  * @covers ::_filterName
  */
 public function testCreate()
 {
     $this->assertInstanceOf(__NAMESPACE__ . '\\Hash', $hash = Hash::create(Hash::NO_CASE_SENSITIVE, ['a' => 'b'], ['c' => 'd'], ['hoge' => 'XYZ'], ['hOgE' => 'ABC']));
     $this->assertTrue($hash->has('HoGe'));
     $this->assertEquals('ABC', $hash->get('HoGe'));
     $this->assertEquals('not_exists', $hash->get('NotExists', 'not_exists'));
     return $hash;
 }
开发者ID:nora-worker,项目名称:core,代码行数:16,代码来源:HashTest.php

示例8: validateUser

 public function validateUser($userName, $password, AuthenticationManager $authenticationManager)
 {
     ResultHelper::whenEqual($password, null, AppLabelUtil::$ERROR_USER_NOT_FOUND, HttpStatusCode::badRequest());
     $user = $this->userService->validateUser($userName, $password);
     ResultHelper::whenEmpty($user, AppLabelUtil::$ERROR_USER_NOT_FOUND, HttpStatusCode::unauthorized());
     $token = Hash::create("sha256", mcrypt_create_iv(64, MCRYPT_DEV_URANDOM), HASH_USER_TOKEN_KEY);
     $authenticationManager->createValidationToken($user->getId(), $user->getRole()->getName(), $token);
     return $this->userMapper->mapUserToDto($user, $token);
 }
开发者ID:euBatham,项目名称:javacature,代码行数:9,代码来源:UserFacade.class.php

示例9: editSave

 public function editSave($data)
 {
     $postData = array('login' => $data['login'], 'password' => Hash::create(HASH_METHOD, $data['password'], HASH_PASSWORD_KEY), 'role' => $data['role'], 'userid' => $data['userid']);
     $this->db->update('users', $postData, "`userid`= {$data['userid']}");
     $res = $this->db->prepare('UPDATE users
           SET `login`=:login, `password`=:password, `role`=:role
           WHERE userid=:userid
           ');
     $res->execute(array(':login' => $data['login'], ':password' => Hash::create(HASH_METHOD, $data['password'], HASH_PASSWORD_KEY), ':role' => $data['role'], ':userid' => $data['userid']));
 }
开发者ID:Ristee,项目名称:mvctest3,代码行数:10,代码来源:User_Model.php

示例10: createResetToken

 public function createResetToken(User $user)
 {
     ResultHelper::whenEmpty($user->getEmail(), AppLabelUtil::$ERROR_USER_NO_EMAIL, HttpStatusCode::internalServerError());
     $tokenHash = Hash::create("sha256", mcrypt_create_iv(64, MCRYPT_DEV_URANDOM), HASH_GENERAL_KEY);
     $this->mailService->setMailHeading(array($user->getEmail() => $user->getFirstName() . " " . $user->getLastName()));
     $this->mailService->setBody("Instellen van uw wachtwoord", "Beste gebruiker, gelieve de volgende link te gebruiken om uw wachtwoord in te stellen: " . URL . "#/reset/token/" . $tokenHash);
     $this->mailService->sendMail();
     $resetToken = $this->resetTokenFactory->createResetToken($user->getId(), $tokenHash);
     $this->resetTokenDao->create($resetToken);
 }
开发者ID:euBatham,项目名称:javacature,代码行数:10,代码来源:ResetTokenService.class.php

示例11: editSave

 public function editSave($data)
 {
     $password = Hash::create('sha256', $data['password'], HASH_PASSWORD_KEY);
     $user = new User();
     $existingUser = $user->findById($data['id']);
     $existingUser->setId($data['id']);
     $existingUser->setLogin($data['login']);
     $existingUser->setPassword($password);
     $existingUser->setRole($data['role']);
     $existingUser->update(true);
 }
开发者ID:sks40gb,项目名称:sks,代码行数:11,代码来源:UserModel.php

示例12: editSave

 public function editSave($id)
 {
     //Form is posted from the Edit page, Do the Error check
     $data = array();
     $data['id'] = $id;
     $data['login'] = $_POST['login'];
     $data['password'] = Hash::create('sha256', $_POST['password'], HASH_KEY);
     $data['role'] = $_POST['role'];
     //Do the Error checking
     $this->model->RunEditSave($data);
     header('location: ' . URL . 'users');
 }
开发者ID:saptharsh,项目名称:Project-Management-App,代码行数:12,代码来源:users.php

示例13: update

 /**
  * update
  * @param String  $table A name of table to insert into
  * @param String  $data An associative array
  * @param String  $where the WHERE query part
  */
 public function update($table, $data, $where)
 {
     ksort($data);
     $data['password'] = Hash::create('md5', $data['password'], HASH_KEY);
     $arrTemp = array();
     foreach ($data as $key => $value) {
         $arrTemp[$key] = $key . "=" . "'{$value}'";
     }
     $fieldValues = implode(",", array_values($arrTemp));
     $pquery = $this->prepare("UPDATE {$table} SET {$fieldValues} WHERE {$where}");
     $pquery->execute();
 }
开发者ID:huanpc,项目名称:mini-framework-for-php,代码行数:18,代码来源:Database.php

示例14: clientLogin

 function clientLogin($data)
 {
     $sql = "SELECT client_id,client_username FROM client WHERE client_email = :client_email AND client_pass = :client_pass AND client_is_active = 1";
     $client = array(':client_email' => $data['email_login'], ':client_pass' => Hash::create('md5', $data['pass_login'], HASH_PASSWORD_KEY));
     $result = $this->db->select($sql, $client);
     if (isset($result[0]['client_id'])) {
         Session::init();
         Session::set('client_id', $result[0]['client_id']);
         Session::set('client_username', $result[0]['client_username']);
     }
     echo json_encode($result);
 }
开发者ID:trongloikt192,项目名称:Project_Wahanda_Alternative,代码行数:12,代码来源:clientlogin_model.php

示例15: save

 public function save()
 {
     $password = $this->model->generate_password();
     $this->model->mail($_POST['email'], $_POST['name'], $password);
     $data = array("name" => $_POST['name'], "email" => $_POST['email'], "password" => Hash::create($password));
     if ($_POST['type'] == 'create') {
         $this->model->create($data);
     }
     if ($_POST['type'] == 'edit') {
         $this->model->edit($data, $_POST['id']);
     }
     header("Location: " . URL . "user");
 }
开发者ID:DvOtterloo,项目名称:Questionmark,代码行数:13,代码来源:user_controller.php


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