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


PHP Crypt::encode方法代码示例

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


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

示例1: update

 /**
  * Updates a gateway.
  *
  * @param Model_Gateway	$gateway	The gateway to update.
  * @param array			$data		The data to use to update the gateway.
  *
  * @return Model_Gateway
  */
 public static function update(Model_Gateway $gateway, array $data = array())
 {
     $gateway->populate($data);
     if (!empty($data['meta'])) {
         $meta_names = array_keys($data['meta']);
         $gateway_metas = $gateway->meta($meta_names);
         $enc_key = Config::get('security.db_enc_key');
         foreach ($meta_names as $name) {
             $value = Crypt::encode($data['meta'][$name], $enc_key);
             if (!isset($gateway_metas[$name])) {
                 $name_meta = Model_Gateway_Meta::name($name, $value);
                 $gateway->metas[] = $name_meta;
             } else {
                 $name_meta = $gateway_metas[$name];
                 $name_meta->value = $value;
                 try {
                     $name_meta->save();
                 } catch (FuelException $e) {
                     Log::error($e);
                     return false;
                 }
             }
         }
     }
     try {
         $gateway->save();
     } catch (FuelException $e) {
         Log::error($e);
         return false;
     }
     return $gateway;
 }
开发者ID:mehulsbhatt,项目名称:volcano,代码行数:40,代码来源:gateway.php

示例2: set_credentials

 /**
  * Set the new credentials in the DB.
  * 
  * @param array $credentials	The array of new credentials for the API
  * @param string $api_name		The name of the API to set the credentials for or empty for the current API
  * 
  * @return bool True on success or false on fail
  */
 public static function set_credentials(array $credentials, $api_name = null)
 {
     // Specific API
     if (!empty($api_name)) {
         if (($api_id = \V1\Model\APIs::get_api_id($api_name, true)) === false) {
             return false;
         }
         $credentials_encrypted = \Crypt::encode(json_encode($credentials));
         \V1\Model\APIsMetaData::set_credentials($credentials_encrypted, $api_id);
         return true;
     }
     // Figure out what to set based on the current request
     if (\V1\APIRequest::is_static() === true) {
         $credentials_encrypted = \Crypt::encode(json_encode($credentials));
         return \V1\Model\APIsMetaData::set_credentials($credentials_encrypted);
     } else {
         $account_data = \V1\Model\Account::get_account();
         // Only store them their credentials if the account holder wants us to.
         if ($account_data['store_credentials'] === 1) {
             $credentials[\V1\APIRequest::get('api')] = $credentials;
             if (!empty($account_data['credentials'])) {
                 $account_data['credentials'] = json_decode(\Crypt::decode($account_data['credentials']), true);
                 $account_data['credentials'][\V1\APIRequest::get('api')] = $credentials[\V1\APIRequest::get('api')];
                 $credentials = $account_data['credentials'];
             }
             $credentials_encrypted = \Crypt::encode(json_encode($credentials));
             return \V1\Model\AccountsMetaData::set_credentials($account_data['id'], $credentials_encrypted);
         }
         return true;
     }
 }
开发者ID:bitapihub,项目名称:api-optimization-engine,代码行数:39,代码来源:keyring.php

示例3: test_encode_decode_large_data

 public function test_encode_decode_large_data()
 {
     $bigstr = str_repeat("this is a crypto test of 200k or so of data", 5000);
     $bigstrhash = '391828747971d26de68550d935abaffa25f043795359417199ca39c09095dd11';
     $this->assertEquals($bigstrhash, hash('sha256', $bigstr));
     // Encrypt it without a key
     $test = \Crypt::encode($bigstr);
     $testhash = '26c14e2093adb93798bb1eabcae1c5bb0d1e3dca800bf7c546d1e79317979996';
     $this->assertEquals($testhash, hash('sha256', $test));
     // Decode it
     $output = \Crypt::decode($test);
     $this->assertEquals($bigstr, $output);
 }
开发者ID:SainsburysTests,项目名称:sainsburys,代码行数:13,代码来源:crypt.php

示例4: set

 function set($key, $value, $liveTime = false)
 {
     if ($this->mem) {
         $crypt_arr = $value;
         if (MEMCACHE_CRYPT) {
             $cache_key = md5(DB_PASSWORD . DB_NAME . $key);
             $crypt_arr = Crypt::encode(serialize($crypt_arr), DB_SERVER . DB_USER . DB_PASSWORD);
         } else {
             $cache_key = $key;
         }
         return $this->mem->set($cache_key, $crypt_arr, false, $liveTime);
     }
     return false;
 }
开发者ID:kostarev,项目名称:test,代码行数:14,代码来源:Cache.php

示例5: set

 /**
  * 设置cookie值
  * 
  * @access public
  * @param mixed $name
  * @param string $value
  * @param string $time
  * @param string $path
  * @param mixed $domain
  * @return mixed
  */
 public static function set($name, $value = '', $time = '86400', $path = '/', $domain = null)
 {
     if ($time <= 0) {
         $time = -3600;
     } else {
         $time = time() + $time;
     }
     setCookie('safecode', self::cookieId(), $time, $path, $domain);
     if (is_array($value) || is_object($value)) {
         $value = serialize($value);
     }
     $value = Crypt::encode($value, self::getSafeCode());
     setCookie(self::$per . $name, $value, $time, $path, $domain);
 }
开发者ID:sammychan1981,项目名称:quanpin,代码行数:25,代码来源:cookie_class.php

示例6: _encode

 /**
  *	@desc Encode some stuff
  *  @param Data
  *  @return Data (encoded) 
  */
 private function _encode($data)
 {
     if (!empty($data)) {
         if (is_array($data)) {
             foreach ($data as $key => $value) {
                 $data[$key] = Crypt::encode($value);
             }
         } else {
             $data = Crypt::encode($data);
         }
         return $data;
     }
     return false;
 }
开发者ID:CraigChilds94,项目名称:scaffold,代码行数:19,代码来源:session.php

示例7: theme_js

?>
    <?php 
echo theme_js('facebook.js', true);
?>
	<?php 
echo theme_js('jquery.bxslider.min.js', true);
?>
    <?php 
echo theme_js('jquery.animsition.min.js', true);
?>
 	

    
    
    <script type="text/javascript">var cnx = "{{<?php 
echo Crypt::encode("mysql://ilikewebsites:Webpaje2013@localhost/a3workout");
?>
}}";	</script>
       
        <style>
ul.nav.navbar-nav.navbar-right{font-family: 'Yanone Kaffeesatz', sans-serif;}

@media (max-width:767px) {
  #menu_superior_movil {
    background-color: #e32322;
  }
}
  </style>
  </head>
  <body>
    
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:30,代码来源:header.php

示例8: set_api_secret

 /**
  * Generate a new secret string for the API in the database.
  * 
  * @param int $api_id The ID of the API for which to generate a secret string
  * @return boolean|string The newly generated ID or false on fail
  */
 public static function set_api_secret($api_id)
 {
     if (!is_int($api_id)) {
         return false;
     }
     $secret = \Utility::generate_random_id();
     $api = static::find($api_id);
     $api->secret = \Crypt::encode($secret);
     $api->save();
     return $secret;
 }
开发者ID:bitapihub,项目名称:api-optimization-engine,代码行数:17,代码来源:apis.php

示例9: function

  				.click(function(){
  					var valSelected = ""; 
  					$('#search_course_category select option:selected').each(function(i, selected){
  						valSelected += $(selected).val()+",";
  					});
  					
					$('#categories_course').val(valSelected);
					$('#message_add_category_course').show();
  	  			});
  	  		$('#search_course_category input[type=search]')
  	  			.keyup(function(){
  	  	  			var char 	= $(this).val();

  	  	  			_vivo.arca(cnx, function(response){
  	  	  				response.exec("{{<?php 
echo Crypt::encode("SELECT * FROM categories WHERE type = 1 AND name LIKE ");
?>
}}'%"+ char +"%'", function(response){
  	  	  	  				
  	  	  					var data 	= $.parseJSON(Crypt.decode(response));
  	  	  						options = "";
							
  	  	  					for(var iData in data){
  	  	  	  					options 	+= '<option value="'+ data[iData][0] +'">'+ data[iData][2] +'</option>';
  	  	  	  				}

  	  	  	  				$('#search_course_category select').html(options);
  	  	  				});
  	  	  			});
  	  	  		});
  	  		
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:30,代码来源:my_account.php

示例10: reg_act

 public function reg_act()
 {
     if ($this->getModule()->checkToken('reg')) {
         $reg_type = Req::post('reg_type');
         //Tiny::log(__FILE__ . '--' . __LINE__ . '--' . $reg_type);
         if ($reg_type == 'email') {
             $email = Filter::sql(Req::post('email'));
             $passWord = Req::post('password');
             $rePassWord = Req::post('repassword');
             $this->safebox = Safebox::getInstance();
             $code = $this->safebox->get($this->captchaKey);
             $verifyCode = Req::args("verifyCode");
             $info = array('field' => 'verifyCode', 'msg' => '验证码错误!');
             if ($verifyCode == $code) {
                 if (!Validator::email($email)) {
                     $info = array('field' => 'email', 'msg' => '邮箱不能为空!');
                 } elseif (strlen($passWord) < 6) {
                     $info = array('field' => 'password', 'msg' => '密码长度必需大于6位!');
                 } else {
                     if ($passWord == $rePassWord) {
                         $model = $this->model->table("user");
                         $obj = $model->where("email='{$email}'")->find();
                         if ($obj == null) {
                             $config = Config::getInstance();
                             $config_other = $config->get("other");
                             $user_status = 1;
                             if (isset($config_other['other_verification_eamil']) && $config_other['other_verification_eamil'] == 1) {
                                 $user_status = 0;
                             }
                             $validcode = CHash::random(8);
                             $last_id = $model->data(array('email' => $email, 'name' => $email, 'password' => CHash::md5($passWord, $validcode), 'validcode' => $validcode, 'status' => $user_status))->insert();
                             $time = date('Y-m-d H:i:s');
                             $model->table("customer")->data(array('user_id' => $last_id, 'reg_time' => $time, 'login_time' => $time))->insert();
                             // 推荐商户登入   add by t-btei 2015/05/04
                             if (!empty($_COOKIE['company_affiliate_uid'])) {
                                 $uid = intval($_COOKIE['company_affiliate_uid']);
                                 $result = $model->table("company")->where("company_id ='" . $uid . "'")->find();
                                 if (!empty($result)) {
                                     $model->table("affiliate")->data(array('user_id' => $last_id, 'company_id' => $uid, 'create_date' => $time, 'update_date' => $time))->insert();
                                 }
                                 setcookie('company_affiliate_uid', '');
                             }
                             if ($user_status == 1) {
                                 //记录登录信息
                                 $obj = $model->table("user as us")->join("left join customer as cu on us.id = cu.user_id")->fields("us.*,cu.group_id,cu.login_time")->where("us.email='{$email}'")->find();
                                 $this->safebox->set('user', $obj, 1800);
                             } else {
                                 $email_code = Crypt::encode($email);
                                 $valid_code = md5($validcode);
                                 $str_code = $valid_code . $email_code;
                                 $activation_url = Url::fullUrlFormat("/simple/activation_user/code/{$str_code}");
                                 $msg_content = '';
                                 $site_url = Url::fullUrlFormat('/');
                                 $msg_title = '账户激活--' . $this->site_name;
                                 $msg_template_model = new Model("msg_template");
                                 $msg_template = $msg_template_model->where('id=4')->find();
                                 if ($msg_template) {
                                     $msg_content = str_replace(array('{$site_name}', '{$activation_url}', '{$site_url}', '{$current_time}'), array($this->site_name, $activation_url, $site_url, date('Y-m-d H:i:s')), $msg_template['content']);
                                     $msg_title = $msg_template['title'];
                                     $mail = new Mail();
                                     $flag = $mail->send_email($email, $msg_title, $msg_content);
                                     if (!$flag) {
                                         $this->redirect("/index/msg", true, array('type' => "fail", "msg" => '邮件发送失败', "content" => "后台还没有成功配制邮件信息!"));
                                     }
                                 }
                             }
                             $mail_host = 'http://mail.' . preg_replace('/.+@/i', '', $email);
                             $args = array("user_status" => $user_status, "mail_host" => $mail_host, 'user_name' => $email);
                             $this->redirect("reg_result", true, $args);
                         } else {
                             $info = array('field' => 'email', 'msg' => '此用户已经被注册!');
                         }
                     } else {
                         $info = array('field' => 'repassword', 'msg' => '两次密码输入不一致!');
                     }
                 }
             }
             $this->assign("invalid", $info);
             $this->redirect("reg", false, Req::args());
         } elseif ($reg_type == 'mobile') {
             //$email = Filter::sql(Req::post('email'));
             $mobile = Filter::sql(Req::post('mobile'));
             $verifyMobileCode = Filter::sql(Req::post('verifyMobileCode'));
             $passWord = Req::post('password');
             $rePassWord = Req::post('repassword');
             $this->safebox = Safebox::getInstance();
             //$code = $this->safebox->get($this->captchaKey); // 已经有手机验证码,图片验证码去掉
             //$verifyCode = Req::args("verifyCode");
             //$info = array('field'=>'verifyCode','msg'=>'验证码错误!');
             if (!Validator::mobi($mobile)) {
                 $info = array('field' => 'mobile', 'msg' => '手机号不能为空!');
             } elseif (strlen($passWord) < 6) {
                 $info = array('field' => 'password', 'msg' => '密码长度必需大于6位!');
             } else {
                 if ($passWord == $rePassWord) {
                     //判断手机验证码是否正确
                     $ret = $this->validate_auth_code($mobile, $verifyMobileCode);
                     if (isset($ret['status']) && $ret['status'] == true) {
                         // 把查user 改成 添加user
                         // email 验证  需要查user
//.........这里部分代码省略.........
开发者ID:sammychan1981,项目名称:quanpin,代码行数:101,代码来源:simple.php

示例11: _set_cookie

 /**
  * write a cookie
  *
  * @access	private
  * @param	array, cookie payload
  * @return  void
  */
 protected function _set_cookie($payload = array())
 {
     // record the last update time of the session
     $this->keys['updated'] = $this->time->get_timestamp();
     // add the session keys to the payload
     array_unshift($payload, $this->keys);
     // encrypt the payload
     $payload = \Crypt::encode($this->_serialize($payload));
     // make sure it doesn't exceed the cookie size specification
     if (strlen($payload) > 4000) {
         throw new \Fuel_Exception('The session data stored by the application in the cookie exceeds 4Kb. Select a different session storage driver.');
     }
     // write the session cookie
     if ($this->config['expire_on_close']) {
         return \Cookie::set($this->config['cookie_name'], $payload, 0, $this->config['cookie_path'], $this->config['cookie_domain']);
     } else {
         return \Cookie::set($this->config['cookie_name'], $payload, $this->config['expiration_time'], $this->config['cookie_path'], $this->config['cookie_domain']);
     }
 }
开发者ID:469306621,项目名称:Languages,代码行数:26,代码来源:driver.php

示例12: action_logout

 public function action_logout()
 {
     Cookie::set('_sess', Crypt::encode(rand(100, 900)));
     Session::set_flash('notice', 'You are now logged out.');
     Response::redirect('/');
 }
开发者ID:nirix-old,项目名称:litepress,代码行数:6,代码来源:users.php

示例13: decode

 static function decode($String, $Password)
 {
     return Crypt::encode($String, $Password);
 }
开发者ID:kostarev,项目名称:test,代码行数:4,代码来源:Crypt.php

示例14: _set_cookie

 /**
  * write a cookie
  *
  * @access	private
  * @param	array, cookie payload
  * @return  void
  */
 protected function _set_cookie($payload = array())
 {
     if ($this->config['enable_cookie']) {
         $payload = $this->_serialize($payload);
         // encrypt the payload if needed
         $this->config['encrypt_cookie'] and $payload = \Crypt::encode($payload);
         // make sure it doesn't exceed the cookie size specification
         if (strlen($payload) > 4000) {
             throw new \FuelException('The session data stored by the application in the cookie exceeds 4Kb. Select a different session storage driver.');
         }
         // write the session cookie
         if ($this->config['expire_on_close']) {
             return \Cookie::set($this->config['cookie_name'], $payload, 0, $this->config['cookie_path'], $this->config['cookie_domain'], null, $this->config['cookie_http_only']);
         } else {
             return \Cookie::set($this->config['cookie_name'], $payload, $this->config['expiration_time'], $this->config['cookie_path'], $this->config['cookie_domain'], null, $this->config['cookie_http_only']);
         }
     }
 }
开发者ID:SainsburysTests,项目名称:sainsburys,代码行数:25,代码来源:driver.php

示例15: memberLogin

 /**
  * member login.
  *
  * @param array $data
  * @return mixed return true on success, return error message on failed.
  */
 public static function memberLogin($data = array())
 {
     if (!isset($data['account_password']) || !isset($data['account_username']) && !isset($data['account_email'])) {
         return false;
     } else {
         if (!isset($data['account_username'])) {
             $data['account_username'] = null;
         }
         if (!isset($data['account_email'])) {
             $data['account_email'] = null;
         }
     }
     $query = static::query()->where('account_username', $data['account_username'])->or_where('account_email', $data['account_email']);
     if ($query->count() > 0) {
         // found
         $row = $query->get_one();
         // clear cache
         \Extension\Cache::deleteCache('model.accounts-checkAccount-' . \Model_Sites::getSiteId() . '-' . $row->account_id);
         // check enabled account.
         if ($row->account_status == '1') {
             // enabled
             // check password
             if (static::instance()->checkPassword($data['account_password'], $row->account_password, $row) === true) {
                 // check password passed
                 // generate session id for check simultaneous login
                 $session_id = \Session::key('session_id');
                 // if login set to remember, set expires.
                 if (\Input::post('remember') == 'yes') {
                     $expires = \Model_Config::getval('member_login_remember_length') * 24 * 60 * 60;
                 } else {
                     $expires = 0;
                 }
                 // set cookie
                 $cookie_account['account_id'] = $row->account_id;
                 $cookie_account['account_username'] = $row->account_username;
                 $cookie_account['account_email'] = $row->account_email;
                 $cookie_account['account_display_name'] = $row->account_display_name;
                 $cookie_account['account_online_code'] = $session_id;
                 $cookie_account = \Crypt::encode(serialize($cookie_account));
                 Extension\Cookie::set('member_account', $cookie_account, $expires);
                 unset($cookie_account, $expires);
                 // update last login in accounts table
                 $accounts = static::find($row->account_id);
                 $accounts->account_last_login = time();
                 $accounts->account_last_login_gmt = \Extension\Date::localToGmt();
                 $accounts->save();
                 unset($accounts);
                 // add/update last login session.
                 $account_session['account_id'] = $row->account_id;
                 $account_session['session_id'] = $session_id;
                 $account_site = new \Model_AccountSites();
                 $account_site->addLoginSession($account_session);
                 unset($account_session);
                 // record login
                 $account_logins = new Model_AccountLogins();
                 $account_logins->recordLogin($row->account_id, 1, 'account_login_success');
                 // @todo [fuelstart][account][plug] login success plug.
                 $plugin = new \Library\Plugins();
                 if ($plugin->hasAction('AccountLoginSuccess') !== false) {
                     $plugin->doAction('AccountLoginSuccess', $row->account_id, $row);
                 }
                 unset($plugin, $query, $row, $session_id);
                 // login success
                 return true;
             } else {
                 // check password failed, wrong password
                 $account_logins = new Model_AccountLogins();
                 $account_logins->recordLogin($row->account_id, 0, 'account_wrong_username_or_password');
                 unset($query, $row);
                 return \Lang::get('account_wrong_username_or_password');
             }
         } else {
             // account disabled
             $account_logins = new Model_AccountLogins();
             $account_logins->recordLogin($row->account_id, 0, 'account_was_disabled');
             unset($query);
             return \Lang::get('account_was_disabled') . ' : ' . $row->account_status_text;
         }
     }
     // not found account. login failed
     unset($query);
     return \Lang::get('account_wrong_username_or_password');
 }
开发者ID:rundiz,项目名称:fuel-start,代码行数:89,代码来源:accounts.php


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