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


PHP Crypt类代码示例

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


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


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