本文整理汇总了PHP中Encrypt类的典型用法代码示例。如果您正苦于以下问题:PHP Encrypt类的具体用法?PHP Encrypt怎么用?PHP Encrypt使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Encrypt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __get
/**
* Decrypt the data when taking it out of the database
* @Developer brandon
* @Date May 18, 2010
*/
public function __get($key)
{
$value = parent::__get($key);
if (in_array($key, array('content', 'title'))) {
if ($value) {
$encrypt = new Encrypt();
$value = $encrypt->decode($value);
}
}
return $value;
}
示例2: send
public function send()
{
$c = new Encrypt();
$message = $c->encode(json_encode($this->attributes));
$q = MessageQueue::Get($account);
try {
$q->send($this->queue, $message);
return TRUE;
} catch (AWSException $ex) {
return FALSE;
}
}
示例3: __construct
public function __construct()
{
$this->cookie_name = Lemon::config('session.name') . '_data';
if (Lemon::config('session.encryption')) {
$this->encrypt = Encrypt::instance();
}
}
示例4: __construct
public function __construct()
{
// Load configuration
$config = Kohana::config('session');
if ( ! empty($config['encryption']))
{
// Load encryption
$this->encrypt = Encrypt::instance();
}
if (is_array($config['storage']))
{
if ( ! empty($config['storage']['group']))
{
// Set the group name
$this->db = $config['storage']['group'];
}
if ( ! empty($config['storage']['table']))
{
// Set the table name
$this->table = $config['storage']['table'];
}
}
// Load database
$this->db = Database::instance($this->db);
Kohana::log('debug', 'Session Database Driver Initialized');
}
示例5: registerAction
/**
* 确认注册【设定密码】
* @method registerAction
* @return [type] [description]
* @author NewFuture
*/
public function registerAction()
{
$msg = '信息注册失败!';
if ($regInfo = Session::get('reg')) {
Session::del('reg');
if (Input::post('password', $password, 'trim') === false) {
/*密码未md5*/
$this->error('密码错误', '/');
} elseif (!$password) {
/*未设置密码*/
$password = $regInfo['password'];
}
$regInfo['password'] = Encrypt::encryptPwd($password, $regInfo['number']);
if ($id = UserModel::insert($regInfo)) {
/*注册成功*/
$regInfo['id'] = $id;
$token = Auth::token($regInfo);
Cookie::set('token', [$id => $token]);
unset($regInfo['password']);
Session::set('user', $regInfo);
$msg = '信息注册成功!';
}
}
$this->jump('/', $msg);
}
示例6: verify
/**
* Verify the Facebook credentials.
*
* @throws Kohana_Exception
* @param string the service name
* @return boolean
*/
public function verify($service = MMI_API::SERVICE_FACEBOOK)
{
$access_token = NULL;
if (!array_key_exists('fragment', $_GET)) {
$this->_convert_fragment_to_parameter();
} else {
$fragment = urldecode(Security::xss_clean($_GET['fragment']));
parse_str($fragment, $parms);
$access_token = Arr::get($parms, 'access_token');
unset($parms);
}
// Ensure the access token is set
if (empty($access_token)) {
MMI_Log::log_error(__METHOD__, __LINE__, 'Access token parameter missing');
throw new Kohana_Exception('Access token parameter missing in :method.', array(':method' => __METHOD__));
}
// Load existing data from the database
$auth_config = $this->_auth_config;
$username = Arr::get($auth_config, 'username');
$model;
if (!empty($username)) {
$model = Model_MMI_API_Tokens::select_by_service_and_username($service, $username, FALSE);
} else {
$consumer_key = Arr::get($auth_config, 'api_key');
$model = Model_MMI_API_Tokens::select_by_service_and_consumer_key($service, $consumer_key, FALSE);
}
$success = FALSE;
$previously_verified = FALSE;
if ($model->loaded()) {
// Check if the credentials were previously verified
$previously_verified = $model->verified;
$success = $previously_verified;
}
if (!$previously_verified) {
// Create an access token
$token = new OAuthToken($access_token, $service . '-' . time());
// Update the token credentials in the database
$svc = MMI_API::factory($service);
if (isset($token) and $svc->is_valid_token($token)) {
$encrypt = Encrypt::instance();
$model->service = $service;
$model->consumer_key = 'consumer-' . $service;
$model->consumer_secret = $encrypt->encode($service . '-' . time());
$model->token_key = $token->key;
$model->token_secret = $encrypt->encode($token->secret);
unset($encrypt);
$model->verified = 1;
$model->verification_code = $service . '-' . time();
$model->username = $username;
if (array_key_exists('expires_in', $_GET)) {
$model->attributes = array('expires_in' => urldecode(Security::xss_clean($_GET['expires_in'])));
}
$success = MMI_Jelly::save($model, $errors);
if (!$success and $this->_debug) {
MMI_Debug::dead($errors);
}
}
}
return $success;
}
示例7: encode
public function encode($data)
{
// Set the rand type if it has not already been set
if (Encrypt::$_rand === NULL) {
$is_windows = DIRECTORY_SEPARATOR === '\\';
if ($is_windows) {
// Windows only supports the system random number generator
Encrypt::$_rand = MCRYPT_RAND;
} else {
if (defined('MCRYPT_DEV_URANDOM')) {
// Use /dev/urandom
Encrypt::$_rand = MCRYPT_DEV_URANDOM;
} elseif (defined('MCRYPT_DEV_RANDOM')) {
// Use /dev/random
Encrypt::$_rand = MCRYPT_DEV_RANDOM;
} else {
// Use the system random number generator
Encrypt::$_rand = MCRYPT_RAND;
}
}
}
if (Encrypt::$_rand === MCRYPT_RAND) {
// The system random number generator must always be seeded each
// time it is used, or it will not produce true random results
mt_srand();
}
// Create a random initialization vector of the proper size for the current cipher
$iv = mcrypt_create_iv($this->_iv_size, Encrypt::$_rand);
// Encrypt the data using the configured options and generated iv
$data = mcrypt_encrypt($this->_cipher, $this->_key, $data, $this->_mode, $iv);
// Use base64 encoding to convert to a string
return base64_encode($iv . $data);
}
示例8: verify
/**
* Verify the Flickr credentials.
*
* @throws Kohana_Exception
* @return boolean
*/
public function verify()
{
// Set the service
$service = $this->_service;
if (empty($service)) {
MMI_Log::log_error(__METHOD__, __LINE__, 'Service not set');
throw new Kohana_Exception('Service not set in :method.', array(':method' => __METHOD__));
}
// Ensure the frob is set
$frob = NULL;
if (array_key_exists('frob', $_GET)) {
$frob = urldecode(Security::xss_clean($_GET['frob']));
}
if (empty($frob)) {
MMI_Log::log_error(__METHOD__, __LINE__, 'Frob parameter missing');
throw new Kohana_Exception('Frob parameter missing in :method.', array(':method' => __METHOD__));
}
// Load existing data from the database
$auth_config = $this->_auth_config;
$username = Arr::get($auth_config, 'username');
$model;
if (!empty($username)) {
$model = Model_MMI_API_Tokens::select_by_service_and_username($service, $username, FALSE);
} else {
$model = Jelly::factory('MMI_API_Tokens');
}
$success = FALSE;
if ($model->loaded()) {
// Check if the credentials were previously verified
$previously_verified = $model->verified;
if ($previously_verified) {
$success = TRUE;
} else {
// Create a dummy verification code
$verification_code = $service . '-' . time();
}
// Do database update
if (!$previously_verified) {
// Get an access token
$svc = MMI_API::factory($service);
$token = $svc->get_access_token($verification_code, array('token_key' => $frob, 'token_secret' => $service . '-' . time()));
// Update the token credentials in the database
if (isset($token) and $svc->is_valid_token($token)) {
$model->token_key = $token->key;
$model->token_secret = Encrypt::instance()->encode($token->secret);
$model->verified = 1;
$model->verification_code = $verification_code;
if (!empty($token->attributes)) {
$model->attributes = $token->attributes;
}
$success = MMI_Jelly::save($model, $errors);
if (!$success and $this->_debug) {
MMI_Debug::dead($errors);
}
}
}
}
return $success;
}
示例9: __construct
public function __construct()
{
$this->cookie_name = Eight::config('session.name') . '_data';
if (Eight::config('session.encryption')) {
$this->encrypt = Encrypt::instance();
}
Eight::log('debug', 'Session Cookie Driver Initialized');
}
示例10: __construct
public function __construct()
{
$this->cookie_name = Kohana::config('session.name') . '_data';
if (Kohana::config('session.encryption')) {
$this->encrypt = Encrypt::instance();
}
Kohana_Log::add('debug', 'Session Cookie Driver Initialized');
}
示例11: __get
/**
* Necessary override to enable per-column encryption.
* @param String $column
* @return mixed
*/
public function __get($column)
{
if (in_array($column, $this->_encrypted_compressed_columns)) {
return gzuncompress(Encrypt::instance()->decode(parent::__get($column)));
}
if (in_array($column, $this->_encrypted_columns)) {
return Encrypt::instance()->decode(parent::__get($column));
}
return parent::__get($column);
}
示例12: cookie
/**
* Get or set our $_COOKIE var via . sperated array access
*
* @param key string A period seperated string of array keys and values
* @param value string The value to be set
*
* @return string
*/
static function cookie($key, $value = null)
{
$key = ID . '_' . $key;
if (!is_null($value)) {
//set the cookie expirey to 24 hours time
setcookie($key, Encrypt::encrypt($value), time() + 3600 * 24);
return;
}
return Encrypt::decrypt($_COOKIE[$key]);
}
示例13: GET_emailAction
/**
* 获取用户真实手机
* GET /user/1/email
* @method GET_infoAction
* @param integer $id [description]
* @author NewFuture
*/
public function GET_emailAction($id = 0)
{
$pid = $this->authPrinter();
if (TaskModel::where('use_id', $id)->where('pri_id', $pid)->get('id')) {
$email = UserModel::where('id', '=', $id)->get('email');
$email = $email ? Encrypt::decryptEmail($email) : null;
$this->response(1, $email);
} else {
$this->response(0, '此同学未在此打印过');
}
}
示例14: get
public function get($name, $dec = true, $encKey = '')
{
$enValue = isset($_COOKIE[$name]) ? $_COOKIE[$name] : false;
if (!$enValue) {
return false;
}
if ($dec) {
$encKey = $encKey ?: $this->encCode;
$deValue = Encrypt::auth($enValue, $encKey, 'DECODE');
} else {
$deValue = $value;
}
return $deValue ?: false;
}
示例15: action_company
public function action_company()
{
$visitor_data = Arr::get($_POST, 'data') ? unserialize(Encrypt::instance('statistics')->decode($_POST['data'])) : NULL;
$company = ORM::factory('service', $this->request->param('id'));
if (!$company->loaded() or !$visitor_data) {
return FALSE;
}
$request = Request::factory(Route::get('company_info')->uri(array('id' => $company->id, 'company_type' => Model_Service::$type_urls[$company->type])));
// Если URI не совпадает или истекло время
if ($request->uri() != $visitor_data['uri'] or strtotime(Date::formatted_time()) - $visitor_data['time_created'] > 60) {
return FALSE;
}
$visit_data = array('date' => Date::formatted_time(), 'uri' => $request->uri(), 'directory' => $request->directory(), 'controller' => $request->controller(), 'action' => $request->action(), 'params' => json_encode($request->get_params()), 'client_ip' => $visitor_data['client_ip'], 'referrer' => $visitor_data['referrer']);
ORM::factory('visit')->save_visit($visit_data);
}