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


PHP BlowfishPasswordHasher::hash方法代码示例

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


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

示例1: beforeSave

 public function beforeSave($options = array())
 {
     if (isset($this->data[$this->alias]['password'])) {
         $passwordHasher = new BlowfishPasswordHasher();
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
         $this->data[$this->alias]['password2'] = $passwordHasher->hash($this->data[$this->alias]['password2']);
     }
     return true;
 }
开发者ID:sharminas,项目名称:BlogAppTest,代码行数:9,代码来源:User.php

示例2: beforeSave

 public function beforeSave($options = array())
 {
     $passwordHasher = new BlowfishPasswordHasher();
     $this->data['User']['password'] = $passwordHasher->hash($this->data['User']['password']);
     $this->log("beforesave" . $this->data['User']['password'], 'debug');
     return true;
 }
开发者ID:takuyahasegawahterry,项目名称:cakephp,代码行数:7,代码来源:User.php

示例3: add_api

 public function add_api()
 {
     if ($this->request->is(array('post', 'xml')) && $this->request->data['Trade']['product_id'] > 0 && $this->request->data['Trade']['user_id'] > 0) {
         $this->Trade->create();
         $this->request->data['Trade']['validated'] = 0;
         $this->Trade->Product->id = $this->request->data['Trade']['product_id'];
         $this->Trade->User->id = $this->request->data['Trade']['user_id'];
         $cost = $this->Trade->Product->field('points_value');
         $user_total = $this->Trade->User->field('total_points');
         $available = $this->Trade->Product->field('quantity_available');
         if ($user_total > $cost && $this->Trade->save($this->request->data) && $available > 0) {
             $this->Trade->User->saveField('total_points', $user_total - $cost);
             $this->Trade->Product->saveField('quantity_available', $this->Trade->Product->field('quantity_available') - 1);
             $qrCode = $this->Trade->id . $this->request->data['Trade']['user_id'] . $this->request->data['Trade']['product_id'] . $this->Trade->field('created');
             $passwordHasher = new BlowfishPasswordHasher();
             $qrCode = $passwordHasher->hash($qrCode);
             $this->Trade->saveField('qr_code', $qrCode);
             $message = array(__('The trade has been saved.'));
             $general_response = array('data' => $qrCode, 'status' => 'success', 'message' => $message);
         } else {
             $message = array(__('The trade could not be saved. Please, try again.'));
             $general_response = array('data' => null, 'status' => 'failure', 'message' => $message);
         }
         $this->set(array('general_response' => $general_response, '_serialize' => array('general_response')));
     }
 }
开发者ID:kahsaynishimura,项目名称:EnglishApp,代码行数:26,代码来源:TradesController.php

示例4: beforeSave

 public function beforeSave($options = array())
 {
     // hash the password
     if (isset($this->data[$this->alias]['password'])) {
         $passwordHasher = new BlowfishPasswordHasher();
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
     // initially generate the url // generate default url if user_level_id is 10 or 20 in data
     if (isset($this->data[$this->alias]['email'])) {
         $this->data[$this->alias]['url'] = md5($this->data[$this->alias]['email']);
     } else {
         if (isset($this->data[$this->alias]['user_level_id']) && ($this->data[$this->alias]['user_level_id'] == 10 || $this->data[$this->alias]['user_level_id'] == 20)) {
             $this->data[$this->alias]['url'] = md5(AuthComponent::user('email'));
         }
     }
     //check if user has pre-url, prepend pre-url to url
     if (isset($this->data[$this->alias]['pre_url'])) {
         $this->data[$this->alias]['url'] = $this->data[$this->alias]['pre_url'] . "" . $this->data[$this->alias]['url'];
     }
     // check/set referral for user
     App::uses('CakeSession', 'Model/Datasource');
     $referral_id = CakeSession::read('referral');
     if (!empty($referral_id)) {
         $this->data[$this->alias]['referral_id'] = $referral_id;
         CakeSession::delete('referral');
     }
     return true;
 }
开发者ID:desnudopenguino,项目名称:fitin,代码行数:28,代码来源:User.php

示例5: beforeSave

 public function beforeSave($options = [])
 {
     //パスワードのハッシュ化のため
     if (isset($this->data[$this->alias]['password'])) {
         $passwordHasher = new BlowfishPasswordHasher();
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
     return true;
 }
开发者ID:klapp303,项目名称:sister,代码行数:9,代码来源:Administrator.php

示例6: beforeSave

 public function beforeSave($options = array())
 {
     if (isset($this->data[$this->alias]['password'])) {
         $passwordHasher = new BlowfishPasswordHasher();
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
     if (isset($this->data[$this->alias]['avatar']) && is_array($this->data[$this->alias]['avatar'])) {
         $this->__uploadAvatar($this->data[$this->alias]['avatar']);
     }
     return true;
 }
开发者ID:aptitune,项目名称:app,代码行数:11,代码来源:User.php

示例7: after

 public function after($event = array())
 {
     if (isset($event['create'])) {
         $table = $event['create'];
         $data = null;
         switch ($table) {
             case 'base_types':
                 $data = array(array('name' => __('Beef')), array('name' => __('Bread')), array('name' => __('Egg')), array('name' => __('Fruit')), array('name' => __('Grain')), array('name' => __('Lamb')), array('name' => __('Other')), array('name' => __('Pasta')), array('name' => __('Pork/Ham')), array('name' => __('Poultry')), array('name' => __('Seafood')), array('name' => __('Vegetable')));
                 break;
             case 'courses':
                 $data = array(array('name' => __('Breakfast')), array('name' => __('Snack')), array('name' => __('Lunch')), array('name' => __('Appetizer')), array('name' => __('Side Dish')), array('name' => __('Entree')), array('name' => __('Dessert')), array('name' => __('Beverage')));
                 break;
             case 'difficulties':
                 $data = array(array('name' => __('Easy')), array('name' => __('Intermediate')), array('name' => __('Difficult')), array('name' => __('Expert')));
                 break;
             case 'ethnicities':
                 $data = array(array('name' => __('American')), array('name' => __('Chinese')), array('name' => __('German')), array('name' => __('Greek')), array('name' => __('Indian')), array('name' => __('Italian')), array('name' => __('Japanese')), array('name' => __('Mexican')), array('name' => __('Middle Eastern')), array('name' => __('None')), array('name' => __('Slavic')));
                 break;
             case 'locations':
                 $data = array(array('name' => __('Alcohol')), array('name' => __('Bakery')), array('name' => __('Beans')), array('name' => __('Bread')), array('name' => __('Candy')), array('name' => __('Canned Fruit')), array('name' => __('Canned Meat & Fish')), array('name' => __('Canned Vegetables')), array('name' => __('Coffee, Tea & Cocoa')), array('name' => __('Condiments')), array('name' => __('Cookies')), array('name' => __('Crackers')), array('name' => __('Dairy')), array('name' => __('Deli')), array('name' => __('Drink mix')), array('name' => __('Facial Tissue')), array('name' => __('Free')), array('name' => __('Frozen Foods')), array('name' => __('HABA')), array('name' => __('Hand Soap')), array('name' => __('Hot & Cold Cereal')), array('name' => __('Household Cleaners')), array('name' => __('Juice & Cocktail')), array('name' => __('Kosher/Ethnic')), array('name' => __('Laundry Detergents')), array('name' => __('Meat')), array('name' => __('Natural & Organic')), array('name' => __('Oil/Vinegar/Dressings')), array('name' => __('Pancakes & Syrup')), array('name' => __('Paper Serving Ware')), array('name' => __('Pasta & Sauce')), array('name' => __('Peanut Butter/Jelly/Honey')), array('name' => __('Produce')), array('name' => __('Rice')), array('name' => __('Salty Snacks & Chips')), array('name' => __('Seafood')), array('name' => __('Soda pop')), array('name' => __('Soup')), array('name' => __('Spices')), array('name' => __('Toilet Paper')));
                 break;
             case 'meal_names':
                 $data = array(array('name' => __('Breakfast')), array('name' => __('Lunch')), array('name' => __('Dinner')), array('name' => __('Dessert')));
                 break;
             case 'preparation_methods':
                 $data = array(array('name' => __('Slow cooker')), array('name' => __('Microwave')), array('name' => __('BBQ')), array('name' => __('Canning')));
                 break;
             case 'preparation_times':
                 $data = array(array('name' => __('0 Minutes')), array('name' => __('1-10 Minutes')), array('name' => __('10-30 Minutes')), array('name' => __('30-60 Minutes')), array('name' => __('60+ Minutes')));
                 break;
             case 'price_ranges':
                 $data = array(array('name' => __('$0-$10')), array('name' => __('$10-$15')), array('name' => __('$15-$20')), array('name' => __('$20-$25')), array('name' => __('$25-$30')), array('name' => __('$30+')));
                 break;
             case 'stores':
                 $data = array(array('name' => 'default', 'layout' => '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40'));
                 break;
             case 'units':
                 $data = array(array('id' => 1, 'name' => __('Unit'), 'abbreviation' => 'ea', 'system' => 0, 'sort_order' => 0), array('id' => 2, 'name' => __('Slice'), 'abbreviation' => 'sli', 'system' => 0, 'sort_order' => 0), array('id' => 3, 'name' => __('Clove'), 'abbreviation' => 'clv', 'system' => 0, 'sort_order' => 0), array('id' => 4, 'name' => __('Pinch'), 'abbreviation' => 'pn', 'system' => 0, 'sort_order' => 0), array('id' => 5, 'name' => __('Package'), 'abbreviation' => 'pk', 'system' => 0, 'sort_order' => 0), array('id' => 6, 'name' => __('Can'), 'abbreviation' => 'cn', 'system' => 0, 'sort_order' => 0), array('id' => 7, 'name' => __('Drop'), 'abbreviation' => 'dr', 'system' => 0, 'sort_order' => 0), array('id' => 8, 'name' => __('Bunch'), 'abbreviation' => 'bn', 'system' => 0, 'sort_order' => 0), array('id' => 9, 'name' => __('Dash'), 'abbreviation' => 'ds', 'system' => 0, 'sort_order' => 0), array('id' => 10, 'name' => __('Carton'), 'abbreviation' => 'ct', 'system' => 0, 'sort_order' => 0), array('id' => 11, 'name' => __('Cup'), 'abbreviation' => 'c', 'system' => 1, 'sort_order' => 0), array('id' => 12, 'name' => __('Tablespoon'), 'abbreviation' => 'T', 'system' => 1, 'sort_order' => 0), array('id' => 13, 'name' => __('Teaspoon'), 'abbreviation' => 't', 'system' => 1, 'sort_order' => 0), array('id' => 14, 'name' => __('Pound'), 'abbreviation' => 'lb', 'system' => 1, 'sort_order' => 0), array('id' => 15, 'name' => __('Ounce'), 'abbreviation' => 'oz', 'system' => 1, 'sort_order' => 0), array('id' => 16, 'name' => __('Pint'), 'abbreviation' => 'pt', 'system' => 1, 'sort_order' => 0), array('id' => 17, 'name' => __('Quart'), 'abbreviation' => 'q', 'system' => 1, 'sort_order' => 0), array('id' => 18, 'name' => __('Gallon'), 'abbreviation' => 'gal', 'system' => 1, 'sort_order' => 0), array('id' => 19, 'name' => __('Milligram'), 'abbreviation' => 'mg', 'system' => 2, 'sort_order' => 0), array('id' => 20, 'name' => __('Centigram'), 'abbreviation' => 'cg', 'system' => 2, 'sort_order' => 0), array('id' => 21, 'name' => __('Gram'), 'abbreviation' => 'g', 'system' => 2, 'sort_order' => 0), array('id' => 22, 'name' => __('Kilogram'), 'abbreviation' => 'kg', 'system' => 2, 'sort_order' => 0), array('id' => 23, 'name' => __('Milliliter'), 'abbreviation' => 'ml', 'system' => 2, 'sort_order' => 0), array('id' => 24, 'name' => __('Centiliter'), 'abbreviation' => 'cl', 'system' => 2, 'sort_order' => 0), array('id' => 25, 'name' => __('Liter'), 'abbreviation' => 'l', 'system' => 2, 'sort_order' => 0), array('id' => 26, 'name' => __('Deciliter'), 'abbreviation' => 'dl', 'system' => 2, 'sort_order' => 0), array('id' => 27, 'name' => __('Tablespoon_m'), 'abbreviation' => 'tbsp', 'system' => 2, 'sort_order' => 0), array('id' => 28, 'name' => __('Teaspoon_m'), 'abbreviation' => 'tsp', 'system' => 2, 'sort_order' => 0));
                 break;
             case 'users':
                 $passwordHasher = new BlowfishPasswordHasher();
                 $data = array(array('username' => 'admin', 'password' => $passwordHasher->hash('passwd'), 'name' => 'Administrator', 'access_level' => Configure::read('AuthRoles.admin'), 'email' => 'user@localhost'));
                 break;
             case 'vendors':
                 $data = array(array('name' => 'Presto Fresh Grocery', 'home_url' => 'http://www.prestofreshgrocery.com/', 'add_url' => 'http://www.prestofreshgrocery.com/checkout/cart/add/uenc/a/product/'));
                 break;
             default:
         }
         if ($data) {
             ClassRegistry::init($table)->saveAll($data);
         }
     }
 }
开发者ID:admorgan,项目名称:PHPRecipebook,代码行数:53,代码来源:schema.php

示例8: beforeSave

 public function beforeSave($options = array())
 {
     // a file has been uploaded so grab the filepath
     if (!empty($this->data[$this->alias]['avatar'])) {
         $this->data[$this->alias]['avatar'] = $this->data[$this->alias]['avatar'];
     }
     if (isset($this->data[$this->alias]['password'])) {
         $passwordHasher = new BlowfishPasswordHasher();
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
     return parent::beforeSave($options);
 }
开发者ID:krzysztofglodzik,项目名称:projekt_kulinarny,代码行数:12,代码来源:User.php

示例9: hash

 public function hash()
 {
     if ($this->request->is('post')) {
         $user['username'] = $this->request->data['Page']['username'];
         if (isset($this->request->data['Page']['password'])) {
             App::uses('BlowfishPasswordHasher', 'Controller/Component/Auth');
             $passwordHasher = new BlowfishPasswordHasher();
             $user['password'] = $passwordHasher->hash($this->request->data['Page']['password']);
         }
         $this->set('user', $user);
     }
     $this->set(array('title_for_layout' => __('Generate Hash') . ' - One Day, One Picture'));
 }
开发者ID:kentux,项目名称:1d1p,代码行数:13,代码来源:PagesController.php

示例10: beforeSave

 /**
  * Before Save
  * @param array $options
  * @return boolean
  */
 public function beforeSave($options = array())
 {
     // hash the user's password befor we save it
     if (isset($this->data[$this->alias]['password'])) {
         $passwordHasher = new BlowfishPasswordHasher();
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
     // if we get an updated password, hash it
     if (isset($this->data[$this->alias]['password_update'])) {
         $passwordHasher = new BlowfishPasswordHasher();
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password_update']);
     }
     // fallback to our parent
     return parent::beforeSave($options);
 }
开发者ID:Beef-Bridge,项目名称:CMS-CakePHP,代码行数:20,代码来源:User.php

示例11: signUp

 public function signUp()
 {
     $data = $this->request->data;
     if (isset($data['password'])) {
         $passwordHasher = new BlowfishPasswordHasher();
         $data['password'] = $passwordHasher->hash($data['password']);
     }
     $res = $this->User->save($data);
     if ($res) {
         unset($res['User']['password']);
         $res['message'] = "登録しました。ログインできます。";
     } else {
         $res['message'] = "登録に失敗しました!";
     }
     $this->set(compact('res'));
     $this->set('_serialize', 'res');
 }
开发者ID:nshiwaku,项目名称:rest-study,代码行数:17,代码来源:UsersController.php

示例12: add

 /**
  * add method
  *
  * @return void
  */
 public function add()
 {
     if ($this->request->is('post')) {
         $d = $this->request->data;
         $this->User->create();
         if ($this->User->save($this->request->data)) {
             $passwordHasher = new BlowfishPasswordHasher();
             $link = array('controller' => 'users', 'action' => 'activate', $this->User->id . '-' . $passwordHasher->hash($d['User']['password']));
             App::uses('CakeEmail', 'Network/Email');
             $mail = new CakeEmail('gmail');
             $mail->from('alicemerveille098@gmail.com')->to($d['User']['email'])->subject('Test :: Inscription')->emailFormat('html')->template('signup')->viewVars(array('username' => $d['User']['username'], 'link' => $link))->send();
             $this->Session->setFlash(__('A mail has been sent'), 'flash/success');
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('The user could not be saved. Please, try again.'), 'flash/error');
         }
     }
     $collections = $this->User->Collection->find('list');
     $this->set(compact('collections'));
 }
开发者ID:galabyca,项目名称:nostalgames,代码行数:25,代码来源:UsersController.php

示例13: beforeSave

 public function beforeSave($options = array())
 {
     // Si existe un id de 'User' significa que estamos editando el registro.
     if (!empty($this->data[$this->alias]['id'])) {
         // Si el password de 'User' es enviado como vacio, significa que no se está modificando.
         if (empty($this->data[$this->alias]['password'])) {
             // Recuperamos el password actual de 'User'
             $pass = $this->find('first', ['conditions' => ['id' => $this->data[$this->alias]['id']]]);
             $this->data[$this->alias]['password'] = $pass['User']['password'];
         } else {
             // De no ser asi encriptamos el nuevo password de 'User'
             $passwordHasher = new BlowfishPasswordHasher();
             $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
         }
     } elseif (isset($this->data[$this->alias]['password'])) {
         // De no ser asi estamos creando un nuevo 'User', entonces encriptamos el password
         $passwordHasher = new BlowfishPasswordHasher();
         $this->data[$this->alias]['password'] = $passwordHasher->hash($this->data[$this->alias]['password']);
     }
     return true;
 }
开发者ID:edsonmgoz,项目名称:cakeusers,代码行数:21,代码来源:User.php

示例14: changePassword

 public function changePassword()
 {
     if ($this->request->is('post')) {
         if ($this->request->data['User']['newPassword'] == $this->request->data['User']['newPasswordRepeat']) {
             $passwordHasher = new BlowfishPasswordHasher();
             $user = $this->User->findById($this->Auth->user('id'));
             $user['User']['password'] = $passwordHasher->hash($this->request->data['User']['newPassword']);
             if ($this->User->save($user)) {
                 $this->Session->setFlash(__('Password changed.'), 'flashes/success');
                 return $this->redirect(array('action' => 'index'));
             } else {
                 $this->Session->setFlash(__('Error changing password.'));
                 return $this->redirect(array('action' => 'index'));
             }
         } else {
             $this->Session->setFlash(__('Passwords do not match.'));
             return $this->redirect(array('action' => 'changePassword'));
         }
     }
     $this->set('currentUsername', $this->Auth->user('username'));
 }
开发者ID:rjawor,项目名称:tagging,代码行数:21,代码来源:UsersController.php

示例15: editMember

 function editMember()
 {
     $this->layout = false;
     $this->autoRender = false;
     if (empty($this->request->data)) {
         $response['success'] = false;
         $response['message'] = 'Empty data sent!';
         return json_encode($response);
     }
     $saveData['User']['id'] = $this->request->data['User_id'];
     $saveData['User']['name'] = trim($this->request->data['User_name']);
     $saveData['User']['surname'] = trim($this->request->data['User_surname']);
     $saveData['User']['mail'] = trim($this->request->data['User_mail']);
     $saveData['User']['username'] = trim($this->request->data['User_mail']);
     $saveData['User']['oib'] = trim($this->request->data['User_oib']);
     $saveData['User']['address'] = trim($this->request->data('User_address'));
     $saveData['User']['phone'] = trim($this->request->data('User_phone'));
     $saveData['User']['active'] = trim($this->request->data('User_active'));
     if (!empty($this->request->data['User_password'])) {
         App::uses('BlowfishPasswordHasher', 'Controller/Component/Auth');
         $passwordHasher = new BlowfishPasswordHasher();
         $saveData['User']['password'] = $passwordHasher->hash($this->request->data['User_password']);
     }
     if ($this->User->saveAll($saveData)) {
         $response['success'] = true;
         $response['message'] = __('User successfully saved.');
     } else {
         $response['success'] = false;
         $response['message'] = __('Error while saving. Please contact your Administrator.');
     }
     return json_encode($response);
 }
开发者ID:mirocosic,项目名称:smartsport-inspinia,代码行数:32,代码来源:ClubsController.php


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