• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Crypt类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: insertUser

 function insertUser($userArray)
 {
     $currTimestamp = time();
     $crypt = new Crypt();
     $salt = $crypt->generateSalt();
     $encPass = $crypt->crypt($userArray["password"], $salt);
     $this->db->exec("INSERT INTO users (name,surname,email,salt,password,active,is_admin,created_on) VALUES (:name,:surname,:email,:salt,:password,:active,:is_admin,:created_on)", array(':name' => $userArray["name"], ':surname' => $userArray["surname"], ':email' => $userArray["email"], ':salt' => $salt, ':password' => $encPass, ':active' => 1, ':is_admin' => 1, ':created_on' => time()));
 }
开发者ID:gsalvatori,项目名称:morefree,代码行数:8,代码来源:db.php


示例2: testDecrypt

 /**
  * Tests Crypt->decrypt()
  */
 public function testDecrypt()
 {
     // Encrypt the data
     $encrypted = $this->crypt->encrypt(self::DATA);
     // Decrypt the data
     $decrypted = $this->crypt->decrypt($encrypted);
     $this->assertTrue($decrypted == self::DATA, 'Testing data decryption');
     unset($encrypted, $decrypted);
 }
开发者ID:spekkionu,项目名称:spekkionu-php-class-collection,代码行数:12,代码来源:CryptTest.php


示例3: decrypt

 private static function decrypt($encrypted)
 {
     if (!class_exists('Crypt')) {
         require dirname(__FILE__) . '/crypt.class.php';
     }
     $cypher = new Crypt(Crypt::CRYPT_MODE_HEXADECIMAL, Crypt::CRYPT_HASH_SHA1);
     $cypher->Key = AUTH_KEY;
     return $cypher->decrypt($encrypted);
 }
开发者ID:midi214,项目名称:hacklog-remote-attachment-upyun,代码行数:9,代码来源:hacklogra_upyun.class.php


示例4: testAll

 public function testAll()
 {
     $text = 'this is my plain text';
     $key = 'this is the password';
     $c = new Crypt();
     $cipher = $c->encrypt($key, $text);
     $plain = $c->decrypt($key, $cipher);
     $this->assertSame($text, $plain);
 }
开发者ID:Jaymon,项目名称:Montage,代码行数:9,代码来源:CryptTest.php


示例5: write

 public static function write($session_id, $data)
 {
     // encryption
     $crypt = new Crypt();
     $data = $crypt->encrypt($data);
     $sessions = new Sessions();
     $sessions->session_id = $session_id;
     $sessions->data = $data;
     $s = $sessions->where("session_id = ?", $session_id)->find();
     if (is_null($s)) {
         return $sessions->save();
     }
     $sessions->id = $s->id;
     return $sessions->update();
 }
开发者ID:utumdol,项目名称:codeseed,代码行数:15,代码来源:db_session.class.php


示例6: dologin

 public function dologin()
 {
     $params = Input::all();
     if (empty($params['username'])) {
         Session::flash('error', '用户名必须填写');
         return Redirect::route('login');
     }
     if (empty($params['password'])) {
         Session::flash('error', '密码必须填写');
         return Redirect::route('login');
     }
     if (empty($params['captcha'])) {
         Session::flash('error', '验证码必须填写');
         return Redirect::route('login');
     }
     if (!$this->_validate_captcha($params['captcha'])) {
         Session::flash('error', '验证码错误');
         return Redirect::route('login');
     }
     $password = md5(md5($params['password']));
     $admin = AdminORM::whereUsername($params['username'])->wherePwd($password)->where('status', '<>', BaseORM::DISABLE)->first();
     if (!empty($admin)) {
         Session::flash('success', '登陆成功');
         $admin_id_cookie = Cookie::forever('admin_id', $admin->id);
         $admin_username_cookie = Cookie::forever('admin_username', $admin->username);
         $k_cookie = Cookie::forever('k', Crypt::encrypt($admin->id . $admin->username));
         $login_time_cookie = Cookie::forever('login_time', time());
         $admin->last_login_time = date('Y-m-d H:i:s');
         $admin->save();
         return Redirect::route('home')->withCookie($k_cookie)->withCookie($admin_id_cookie)->withCookie($admin_username_cookie)->withCookie($login_time_cookie);
     } else {
         Session::flash('error', '用户没找到');
         return Redirect::route('login');
     }
 }
开发者ID:mingshi,项目名称:printer-backend,代码行数:35,代码来源:EntryController.php


示例7: data

 private static function data()
 {
     $title = Http::getParam('title');
     $content = Http::getParam('content');
     $title = Crypt::EnCrypt($title, uniqid());
     Article::putArticle(self::getIndex(), json_encode(array('title' => $title, 'content' => Crypt::EnCrypt($content, uniqid()))));
 }
开发者ID:hhz1084,项目名称:YObject,代码行数:7,代码来源:put.php


示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Requests\SignUpRequest $request)
 {
     //
     $usermodel = new User();
     $all = $request->all();
     try {
         $password = $all["password"];
         $payload = \Crypt::encrypt($password);
         $all["password"] = $payload;
         $all['role'] = 5;
         if (isset($all['_token'])) {
             unset($all['_token']);
         }
         $user = $usermodel->newUser($all);
         if ($user) {
             $login = $this->login($all);
             return $login;
         }
         dd("signup failed!");
     } catch (Exception $e) {
         $message = $e->getMessage();
         $code = $e->getCode();
         dd(["message" => $message, "code" => $code]);
     }
 }
开发者ID:kits2code,项目名称:ignore,代码行数:31,代码来源:SignUpController.php


示例9: down

 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     $gateways = DB::table('account_gateways')->get(['id', 'config']);
     foreach ($gateways as $gateway) {
         DB::table('account_gateways')->where('id', $gateway->id)->update(['config' => Crypt::decrypt($gateway->config)]);
     }
 }
开发者ID:magicians,项目名称:invoiceninja,代码行数:12,代码来源:2015_11_01_080417_encrypt_tokens.php


示例10: getHomeOverview

 public static function getHomeOverview()
 {
     $db = Auth::user()->targets()->where('closed', '=', 0)->orderBy('duedate', 'DESC')->get();
     $ids = array();
     $data = array();
     foreach ($db as $t) {
         $ids[] = intval($t->id);
         $tr = array('id' => $t->id, 'description' => Crypt::decrypt($t->description), 'amount' => floatval($t->amount), 'duedate' => $t->duedate != '0000-00-00' ? new DateTime($t->duedate) : null, 'startdate' => $t->startdate != '0000-00-00' ? new DateTime($t->startdate) : null, 'account' => intval($t->account_id), 'saved' => 0);
         $tr['pct'] = round($tr['saved'] / $tr['amount'] * 100, 2);
         $data[intval($t->id)] = $tr;
     }
     if (count($ids) > 0) {
         $transfers = Auth::user()->transfers()->whereIn('target_id', $ids)->where('date', '<=', Session::get('period')->format('Y-m-d'))->get();
         foreach ($transfers as $t) {
             if ($t->account_from == $data[$t->target_id]['account']) {
                 $data[intval($t->target_id)]['saved'] -= floatval($t->amount);
             } else {
                 if ($t->account_to == $data[$t->target_id]['account']) {
                     $data[intval($t->target_id)]['saved'] += floatval($t->amount);
                 }
             }
         }
     }
     return $data;
 }
开发者ID:jcyh,项目名称:nder-firefly,代码行数:25,代码来源:Target.php


示例11: index

 public function index()
 {
     $encryptedkey = Crypt::encrypt("joomla");
     Config::set('session.driver', 'native');
     Session::put('api_key', $encryptedkey);
     return Response::json(array('status' => 'OK', '_token' => $encryptedkey));
 }
开发者ID:eufelipemartins,项目名称:edlara,代码行数:7,代码来源:ApiController.php


示例12: run

 public function run()
 {
     $data = $this->_context->get("data", '');
     // Log::Write('【加密数据】Remote Accept:' . $data, Log::DEBUG);
     if ($this->_context->isPOST()) {
         $de_data = Crypt::decrypt($data, App::getConfig('YUC_SECURE_KEY'));
         //  Log::Write('解析的加密数据:' . $de_data, Log::DEBUG);
         $post = json_decode($de_data, TRUE);
         if ($post != '' && is_array($post) && $post['site_key'] == md5(App::getConfig('YUC_SITE_KEY'))) {
             $mod = $post['mod'];
             $act = $post['act'];
             $class = 'Remote_' . $mod;
             if ($act == 'show' && $mod == 'Logs') {
                 $name = $post['name'];
                 $obj = new $class();
                 //self::$_string[' $name']=$name;
                 $ret = $obj->{$act}($name);
             } else {
                 $obj = new $class();
                 $ret = $obj->{$act}();
             }
             Log::Write('Remote Run:' . $mod . ',' . $act . ',' . $ret, Log::DEBUG);
             _returnCryptAjax($ret);
         } else {
             Log::Write('安全认证错误!', Log::DEBUG);
             _returnCryptAjax(array('result' => 0, 'content' => '安全认证比对错误错误!'));
         }
     } else {
         Log::Write('远程控制错误!数据并非POST交互!', Log::DEBUG);
         _returnCryptAjax(array('result' => 0, 'content' => '远程控制错误!数据并非POST交互!'));
     }
 }
开发者ID:saintho,项目名称:phpdisk,代码行数:32,代码来源:execute.php


示例13: rules

 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     switch ($this->method()) {
         // Create
         case 'POST':
             // rules
             $rules['group_name'] = "required|unique:groups,name";
             $rules['slug_name'] = "required|unique:groups,slug";
             if (!count($this->permissions)) {
                 //if permission count equal zero
                 $rules['permissions'] = "required";
             }
             return $rules;
             break;
             // Update
         // Update
         case 'PUT':
             // rules
             $rules['group_name'] = 'required|unique:groups,name,' . \Crypt::decrypt($this->get('id'));
             $rules['slug_name'] = 'required|unique:groups,slug,' . \Crypt::decrypt($this->get('id'));
             if (!count($this->permissions)) {
                 //if permission count equal zero
                 $rules['permissions'] = "required";
             }
             return $rules;
             break;
     }
 }
开发者ID:pinnaclesoftware,项目名称:Work-Tracking-System,代码行数:33,代码来源:GroupRequest.php


示例14: getModificar

 public function getModificar($id)
 {
     $usuario = Usuario::find($id);
     $roles = Rol::all();
     $contrasenia = Crypt::decrypt($usuario->contrasenia);
     return View::make("usuarios.modificar")->with("usuario", $usuario)->with("roles", $roles)->with("contrasenia", $contrasenia);
 }
开发者ID:omarmurcia,项目名称:AHJNProject,代码行数:7,代码来源:UsuariosController.php


示例15: saveUserInfo

 public function saveUserInfo()
 {
     if (!isset($_SESSION)) {
         session_start();
     }
     $code = \Input::get('code');
     $lti = \Input::get('lti');
     $instanceFromDB = LtiConfigurations::find($lti);
     $clientId = $instanceFromDB['DeveloperId'];
     $developerSecret = $instanceFromDB['DeveloperSecret'];
     $opts = array('http' => array('method' => 'POST'));
     $context = stream_context_create($opts);
     $url = "https://{$_SESSION['domain']}/login/oauth2/token?client_id={$clientId}&client_secret={$developerSecret}&code={$code}";
     $userTokenJSON = file_get_contents($url, false, $context, -1, 40000);
     $userToken = json_decode($userTokenJSON);
     $actualToken = $userToken->access_token;
     $encryptedToken = \Crypt::encrypt($actualToken);
     $_SESSION['userToken'] = $encryptedToken;
     //store encrypted token in the database
     $courseId = $_SESSION['courseID'];
     $userId = $_SESSION['userID'];
     //make sure we have the user stored in the user table and in the userCourse table.
     $roots = new Roots();
     //when we get the user from the LMS it gets stored in the DB.
     $roots->getUser($userId);
     $dbHelper = new DbHelper();
     $role = $dbHelper->getRole('Approver');
     $userCourse = UserCourse::firstOrNew(array('user_id' => $userId, 'course_id' => $courseId));
     $userCourse->user_id = $userId;
     $userCourse->course_id = $courseId;
     $userCourse->role = $role->id;
     $userCourse->encrypted_token = $encryptedToken;
     $userCourse->save();
     echo "App has been approved. Please reload this page";
 }
开发者ID:Poornimagaurav,项目名称:delphinium,代码行数:35,代码来源:OAuthResponse.php


示例16: login

 public function login(Request $request)
 {
     //        dd(\Crypt::encrypt('[email protected]'));
     try {
         $email = \Crypt::decrypt($request->get('token'));
     } catch (\Exception $e) {
         return abort('403', 'Forbidden');
     }
     $user = User::whereEmail($email)->first();
     if (!$user) {
         return abort('403', 'Forbidden');
     }
     if (!$user->account) {
         $b2bCompany = \DB::connection('mysql-b2b')->table('companies')->where('user_id', '=', $user->id)->first();
         //            $b2bCompany = false;
         $accountName = $b2bCompany ? $b2bCompany->company_name : $user->email;
         $account = new Account();
         $account->ip = $request->getClientIp();
         $account->name = $accountName;
         $account->account_key = str_random(RANDOM_KEY_LENGTH);
         $account->save();
         $user->account_id = $account->id;
         $user->registered = true;
         $user->save();
         $exists = \DB::connection('mysql')->table('users')->whereId($user->id)->count();
         if (!$exists) {
             \DB::connection('mysql')->table('users')->insert(['id' => $user->id, 'account_id' => $user->account_id, 'created_at' => $user->created_at, 'updated_at' => $user->updated_at, 'deleted_at' => $user->deleted_at, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'phone' => $user->phone, 'username' => $user->username, 'email' => $user->email, 'password' => $user->password, 'confirmation_code' => $user->confirmation_code, 'registered' => $user->registered, 'confirmed' => $user->confirmed, 'notify_sent' => $user->notify_sent, 'notify_viewed' => $user->notify_viewed, 'notify_paid' => $user->notify_paid, 'public_id' => $user->public_id, 'force_pdfjs' => false, 'remember_token' => $user->remember_token, 'news_feed_id' => $user->news_feed_id, 'notify_approved' => $user->notify_approved, 'failed_logins' => $user->failed_logins, 'dark_mode' => $user->dark_mode, 'referral_code' => $user->referral_code]);
         }
     }
     \Auth::loginUsingId($user->id);
     return redirect('/');
 }
开发者ID:sseshachala,项目名称:invoiceninja,代码行数:32,代码来源:AutoLoginController.php


示例17: ldap

 /**
  * Authenticates a user to LDAP
  *
  * @param $username
  * @param $password
  * @param bool|false $returnUser
  * @return bool true    if the username and/or password provided are valid
  *              false   if the username and/or password provided are invalid
  *         array of ldap_attributes if $returnUser is true
  */
 function ldap($username, $password, $returnUser = false)
 {
     $ldaphost = Setting::getSettings()->ldap_server;
     $ldaprdn = Setting::getSettings()->ldap_uname;
     $ldappass = Crypt::decrypt(Setting::getSettings()->ldap_pword);
     $baseDn = Setting::getSettings()->ldap_basedn;
     $filterQuery = Setting::getSettings()->ldap_auth_filter_query . $username;
     $ldapversion = Setting::getSettings()->ldap_version;
     // Connecting to LDAP
     $connection = ldap_connect($ldaphost) or die("Could not connect to {$ldaphost}");
     // Needed for AD
     ldap_set_option($connection, LDAP_OPT_REFERRALS, 0);
     ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, $ldapversion);
     try {
         if ($connection) {
             // binding to ldap server
             $ldapbind = ldap_bind($connection, $ldaprdn, $ldappass);
             if (($results = @ldap_search($connection, $baseDn, $filterQuery)) != false) {
                 $entry = ldap_first_entry($connection, $results);
                 if (($userDn = @ldap_get_dn($connection, $entry)) !== false) {
                     if (($isBound = ldap_bind($connection, $userDn, $password)) == "true") {
                         return $returnUser ? array_change_key_case(ldap_get_attributes($connection, $entry), CASE_LOWER) : true;
                     }
                 }
             }
         }
     } catch (Exception $e) {
         LOG::error($e->getMessage());
     }
     ldap_close($connection);
     return false;
 }
开发者ID:chromahoen,项目名称:snipe-it,代码行数:42,代码来源:AuthController.php


示例18: contacto

 public function contacto()
 {
     $mensaje = null;
     $userpass = User::where('email', '=', Input::get('email'))->first();
     if ($userpass) {
         $pass = Crypt::decrypt($userpass->encry);
         $nombre = $userpass->username;
         if (isset($_POST['contacto'])) {
             $data = array('nombre' => $nombre, 'email' => Input::get('email'), 'pass' => $pass);
             $fromEmail = Input::get('email');
             $fromName = Input::get('nombre');
             Mail::send('emails.contacto', $data, function ($message) use($fromName, $fromEmail) {
                 $message->to($fromEmail, $fromName);
                 $message->from('[email protected]', 'administrador');
                 $message->subject('Nuevo Email de contacto');
             });
         }
         return Redirect::to('email')->with('status', 'ok_send');
     } else {
         return Redirect::to('email')->with('status', 'not_send');
     }
     //$data = Input::get('nombre');
     /*foreach ($data as $key => $value) {
     			echo $value.'<br>';
     		}*/
     //echo $data;
     //var_dump($data);
     //return View::make('password.remind')->with('status', 'ok_create');
 }
开发者ID:gabitoooo,项目名称:inventarios,代码行数:29,代码来源:EmailController.php


示例19: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     if ($locale = request()->cookie('locale__myProject')) {
         app()->setLocale(\Crypt::decrypt($locale));
     }
     \Carbon\Carbon::setLocale(app()->getLocale());
 }
开发者ID:linuxssm,项目名称:l5essential,代码行数:12,代码来源:AppServiceProvider.php


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Crypt_AES类代码示例发布时间:2022-05-23
下一篇:
PHP CrugeTranslator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap