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


PHP Crypt_Blowfish类代码示例

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


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

示例1: isDefault

 /**
  * isDefault 
  * 
  * @access public
  * @return bool   false if the user is authenticated, true if not (default user)
  */
 public function isDefault()
 {
     $session =& Framework_Session::singleton();
     if (is_null($session->email)) {
         return true;
     }
     // Check timeout
     $time = time();
     $lastActionTime = $session->lastActionTime;
     $timeLimit = (int) Framework::$site->config->inactiveTimeout;
     $this->recordio("timeout info: time: {$time}, lastActionTime: {$lastActionTime}, timeLimit: {$timeLimit}");
     if ($time - $lastActionTime > $timeLimit) {
         header('Location: ./?module=Login&event=logoutInactive');
         return false;
     }
     // Authenticate
     $encryptedPass = $session->password;
     $crypt = new Crypt_Blowfish((string) Framework::$site->config->mcryptKey);
     $plainPass = $crypt->decrypt($encryptedPass);
     if ($this->authenticate($session->email, $plainPass)) {
         $session->lastActionTime = $time;
         return false;
     }
     return true;
 }
开发者ID:shupp,项目名称:toasteradmin,代码行数:31,代码来源:ToasterAdmin.php

示例2: CheckLicense

function CheckLicense()
{
    global $LKey, $Trial, $SaveVars, $Errors, $Lang, $CLang;
    if (!$LKey && !$Trial) {
        return false;
    }
    if ($LKey) {
        $BF = new Crypt_Blowfish('ns tracker license ');
        $Decoded = $BF->decrypt($LKey);
        $LArray = GetLicenseText($Decoded);
        if ($LArray) {
            if (!isset($LArray['P'])) {
                $Errors[] = $Lang['SecondaryKey'];
                return;
            }
            $GLOBALS['LArray'] = $LArray;
            foreach ($LArray as $Key => $Val) {
                $GLOBALS['Lc' . $Key] = $Val;
                $SaveVars[] = "Lc" . $Key;
            }
        } else {
            $Errors[] = $Lang['BadLicense'];
        }
    }
    if (count($Errors)) {
        return;
    }
    NextStep();
}
开发者ID:juliogallardo1326,项目名称:proc,代码行数:29,代码来源:func.php

示例3: fetchData

 function fetchData($username, $password)
 {
     switch ($this->options['cryptType']) {
         case 'blowfish':
             include_once 'Crypt/Blowfish.php';
             $bf = new Crypt_Blowfish($this->options['cryptKey']);
             $password = $bf->encrypt($password);
             $password = base64_encode($password);
             break;
         default:
             if (function_exists($this->options['cryptType'])) {
                 $password = $this->options['cryptType']($password);
             }
             break;
     }
     $req = new HTTP_Request();
     $req->setURL($this->options['URL']);
     $req->setMethod(HTTP_REQUEST_METHOD_GET);
     $req->addQueryString($this->options['usernameKey'], $username);
     $req->addQueryString($this->options['passwordKey'], $password);
     if (!PEAR::isError($req->sendRequest())) {
         $response = $req->getResponseBody();
     } else {
         return false;
     }
     $unserializer = new XML_Unserializer();
     if ($unserializer->unserialize($response)) {
         $this->result_value = $unserializer->getUnserializedData();
         if ($this->result_value[$this->options['resultKey']] == $this->options['correctValue']) {
             return true;
         }
     }
     return false;
 }
开发者ID:KimuraYoichi,项目名称:PukiWiki,代码行数:34,代码来源:REST_XML.php

示例4: loginNow

 /**
  * loginNow 
  * 
  * Try and log the user in.
  * 
  * @access public
  * @return void
  */
 public function loginNow()
 {
     $this->tplFile = 'Login.tpl';
     $form = $this->createLoginForm();
     if ($form->validate()) {
         $result = $this->user->authenticate($_POST['email'], $_POST['password']);
         if (!$result) {
             $this->setData('loginError', _('Login failed'));
             $this->setData('QF_Form', $form->toHtml());
             $this->session->email = null;
             $this->session->password = null;
             return;
         }
         $crypt = new Crypt_Blowfish((string) Framework::$site->config->mcryptKey);
         $emailArray = explode('@', $_POST['email']);
         $this->session->user = $emailArray[0];
         $this->session->domain = $emailArray[1];
         $this->session->email = $_POST['email'];
         $this->session->password = $crypt->encrypt($_POST['password']);
         $this->session->lastActionTime = time();
         header('Location: ./index.php?module=Home');
         return;
     } else {
         $this->setData('QF_Form', $form->toHtml());
     }
 }
开发者ID:shupp,项目名称:toasteradmin,代码行数:34,代码来源:Login.php

示例5: __construct

 public function __construct($secret)
 {
     $bf = new Crypt_Blowfish('cbc');
     $bf->setKey($secret);
     if (PEAR::isError($bf)) {
         throw new Exception('init error');
     }
     $this->blowfish = $bf;
 }
开发者ID:AF83,项目名称:session-cookie,代码行数:9,代码来源:session.php

示例6: decrypt

 public static function decrypt($sData, $asKey = null)
 {
     if (empty($sData)) {
         throw new Exception("Empty data");
     }
     $sKey = empty($asKey) ? FlexiConfig::$sEncryptionKey : $asKey;
     $blowfish = new Crypt_Blowfish($sKey);
     $sResult = $blowfish->decrypt($sData);
     //    if (strlen($sResult) > 0) {
     //      while (ord($sResult[strlen($sResult)-1]) == 0) {
     //        $sResult = substr($sResult,0,-1);
     //      }
     //    }
     return $sResult;
     //return mcrypt_decrypt( MCRYPT_BLOWFISH, $sKey, $sData, MCRYPT_MODE_CBC, self::getMode() );
 }
开发者ID:u007,项目名称:FlexiPHP,代码行数:16,代码来源:FlexiCryptUtil.php

示例7: __construct

 function __construct()
 {
     $this->cryptFactroy =& Crypt_Blowfish::factory('cbc');
     if (PEAR::isError($this->cryptFactroy)) {
         echo $this->cryptFactroy->getMessage();
         exit;
     }
     $this->iv = 'abc123@%';
     $this->key = 'this is the screct key for bingo';
 }
开发者ID:JasonOcean,项目名称:iOS_Interest_Group,代码行数:10,代码来源:BingoCrypt.php

示例8: decrypt

 public static function decrypt($key, $text)
 {
     if (extension_loaded('mcrypt')) {
         return Crypto::aes128cbcDecrypt($key, $text);
     }
     $iv = substr($text, 0, 8);
     $encrypted = substr($text, 8, strlen($text));
     $blowfish = Crypt_Blowfish::factory('cbc', $key, $iv);
     return base64_decode($blowfish->decrypt($encrypted));
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:10,代码来源:opShindigCrypto.class.php

示例9: decrypt

 public function decrypt($text, $key)
 {
     ${"GLOBALS"}["vomteusqubk"] = "iv";
     set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path());
     ${"GLOBALS"}["bmkhpmirmru"] = "content";
     require_once "Crypt/Blowfish.php";
     ${${"GLOBALS"}["huedivxdprd"]} = \Crypt_Blowfish::factory("cbc");
     ${${"GLOBALS"}["vomteusqubk"]} = "abc123+=";
     $bf->setKey(${${"GLOBALS"}["hrzyuhiegst"]}, ${${"GLOBALS"}["gghvvlla"]});
     ${${"GLOBALS"}["kiurnu"]} = $bf->decrypt(${${"GLOBALS"}["yjfdhdghldod"]});
     return ${${"GLOBALS"}["bmkhpmirmru"]};
 }
开发者ID:cin-system,项目名称:vtigercrm-cin,代码行数:12,代码来源:Utils.php

示例10: __destruct

 public function __destruct()
 {
     if (!defined('TM_SESSION_SAVED')) {
         if ($this->encryption) {
             $cookie =& $this->using('cookie');
             $sess_key = preg_replace('/[^a-zA-Z0-9]/', '', $cookie->get('sess_key'));
             if (strlen($sess_key) == 12) {
                 $bf = new Crypt_Blowfish($sess_key);
                 $data = function_exists('gzcompress') && $this->compress ? gzcompress(serialize($_SESSION)) : serialize($_SESSION);
                 $_SESSION = array();
                 $_SESSION['data'] = $bf->encrypt($data);
                 $_SESSION['pass'] = md5(TM_UNIQUE_STR);
             } else {
                 $_SESSION = array();
             }
         }
         session_write_close();
         $_SESSION = array();
         define('TM_SESSION_SAVED', true);
     }
 }
开发者ID:laiello,项目名称:xiv,代码行数:21,代码来源:session_handler.php

示例11: decrypt

 /**
  * Encrypt data
  *
  * @access	public
  * @static
  * @param	string	$val	Data to encrypt
  * @param	string 	$ky		Key
  * @return	string	Encrypted data
  */
 public static function decrypt($val, $ky = null, $meth = 'cbc')
 {
     if (is_null($ky)) {
         $ky = ENCSALT;
     }
     if (empty($val)) {
         return '';
     }
     $val = base64_decode($val);
     $bf =& Crypt_Blowfish::factory($meth);
     if (PEAR::isError($bf)) {
         throw new Exception($bf->getMessage());
     }
     $iv = 'abc123+=';
     $bf->setKey($ky, $iv);
     $plaintext = $bf->decrypt($val);
     if (PEAR::isError($plaintext)) {
         throw new Exception('decoding error : ' . $plaintext->getMessage());
     }
     return trim($plaintext);
 }
开发者ID:demental,项目名称:m,代码行数:30,代码来源:Crypt.php

示例12: passwordDecrypt

 function passwordDecrypt($encrypt_char)
 {
     if ($encrypt_char == "") {
         return "";
     }
     $encrypted = base64_decode($encrypt_char);
     $blowfish = new Crypt_Blowfish(CBF_KEY);
     $passwd = $blowfish->decrypt($encrypted);
     // 末尾の「\0」を削除
     $passwd = rtrim($passwd, "");
     return $passwd;
 }
开发者ID:honda-kyoto,项目名称:UMS-Kyoto,代码行数:12,代码来源:common_mgr.class.php

示例13: decrypt

 /**
  * @brief decryption of an content
  * @param $content the cleartext message you want to decrypt
  * @param $key the encryption key
  * @returns cleartext content
  *
  * This function decrypts an content
  */
 public static function decrypt($content, $key)
 {
     $bf = new Crypt_Blowfish($key);
     return $bf->encrypt($contents);
 }
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:13,代码来源:owncloud_lib_crypt.php

示例14: inline_crypt_setup

    /**
     * Creates performance-optimized function for de/encrypt(), storing it in $this->inline_crypt
     *
     * @access private
     */
    function inline_crypt_setup()
    {
        /*{{{*/
        $lambda_functions =& Crypt_Blowfish::get_lambda_functions();
        $block_size = 8;
        $mode = $this->mode;
        $code_hash = "{$mode}";
        if (!isset($lambda_functions[$code_hash])) {
            $init_cryptBlock = '

                extract($self->bctx["p"],  EXTR_PREFIX_ALL, "p");

                extract($self->bctx["sb"], EXTR_PREFIX_ALL, "sb");

            ';
            // Generating encrypt code:
            $_encryptBlock = '

                $in = unpack("N*", $in);

                $l = $in[1];

                $r = $in[2];

            ';
            for ($i = 0; $i < 16; $i += 2) {
                $_encryptBlock .= '

                    $l^= $p_' . $i . ';

                    $r^= ($sb_0[$l >> 24 & 0xff]  +

                          $sb_1[$l >> 16 & 0xff]  ^

                          $sb_2[$l >>  8 & 0xff]) +

                          $sb_3[$l       & 0xff];



                    $r^= $p_' . ($i + 1) . ';

                    $l^= ($sb_0[$r >> 24 & 0xff]  +

                          $sb_1[$r >> 16 & 0xff]  ^

                          $sb_2[$r >>  8 & 0xff]) +

                          $sb_3[$r       & 0xff];

                ';
            }
            $_encryptBlock .= '

                $in = pack("N*", $r ^ $p_17, $l ^ $p_16);

            ';
            // Generating decrypt code:
            $_decryptBlock = '

                $in = unpack("N*", $in);

                $l = $in[1];

                $r = $in[2];

            ';
            for ($i = 17; $i > 2; $i -= 2) {
                $_decryptBlock .= '

                    $l^= $p_' . $i . ';

                    $r^= ($sb_0[$l >> 24 & 0xff]  +

                          $sb_1[$l >> 16 & 0xff]  ^

                          $sb_2[$l >>  8 & 0xff]) +

                          $sb_3[$l       & 0xff];



                    $r^= $p_' . ($i - 1) . ';

                    $l^= ($sb_0[$r >> 24 & 0xff]  +

                          $sb_1[$r >> 16 & 0xff]  ^

                          $sb_2[$r >>  8 & 0xff]) +

                          $sb_3[$r       & 0xff];

                ';
            }
            $_decryptBlock .= '
//.........这里部分代码省略.........
开发者ID:Toxatoxa,项目名称:Sample-Code,代码行数:101,代码来源:blowfish.php

示例15: decryptText

function decryptText($text)
{
    require_once 'Crypt/Blowfish.php';
    $bf = new Crypt_Blowfish(ENCRYPTKEY);
    $plaintext = $bf->decrypt(convertString(trim($text)));
    return trim($plaintext);
}
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:7,代码来源:functions.php


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