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


PHP Crypt_Blowfish::encrypt方法代码示例

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


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

示例1: encrypt

 public static function encrypt($sData, $asKey = null)
 {
     $sKey = empty($asKey) ? FlexiConfig::$sEncryptionKey : $asKey;
     $blowfish = new Crypt_Blowfish($sKey);
     return $blowfish->encrypt($sData);
     //return mcrypt_encrypt( MCRYPT_BLOWFISH, $sKey, $sData, MCRYPT_MODE_CBC, self::getMode() );
 }
开发者ID:u007,项目名称:FlexiPHP,代码行数:7,代码来源:FlexiCryptUtil.php

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

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

示例4: encrypt

 public function encrypt($plaintext)
 {
     if (($length = strlen($plaintext)) >= 1048576) {
         return false;
     }
     $ciphertext = '';
     $paddedtext = $this->maxi_pad($plaintext);
     $strlen = strlen($paddedtext);
     for ($x = 0; $x < $strlen; $x += 8) {
         $piece = substr($paddedtext, $x, 8);
         $cipher_piece = parent::encrypt($piece);
         $encoded = base64_encode($cipher_piece);
         $ciphertext = $ciphertext . $encoded;
     }
     return $ciphertext . sprintf('%06d', $length);
 }
开发者ID:jessylenne,项目名称:sf2-technical-test,代码行数:16,代码来源:Blowfish.php

示例5: __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

示例6: strlen

 function wrap_bp_encrypt($cipher_id, $key, $text, $iv)
 {
     if ($cipher_id !== 'blowfish') {
         $last_bp_error = 'PEAR/Crypt/Blowfish: encrypt: unknown_cipher';
         return false;
     }
     $bf = new Crypt_Blowfish('cbc');
     $iv_size = strlen($iv);
     if ($iv_size !== false && $iv_size > 0) {
         $bf->setKey($key, $iv);
     } else {
         $bf->setKey($key);
     }
     if (PEAR::isError($text)) {
         $last_bp_error = 'PEAR/Crypt/Blowfish: encrypt: ' . $text->getMessage();
         return false;
     }
     $text = $bf->encrypt($text);
     if (PEAR::isError($text)) {
         $last_bp_error = 'PEAR/Crypt/Blowfish: encrypt: ' . $text->getMessage();
         return false;
     }
     return $text;
 }
开发者ID:siefca,项目名称:pageprotectionplus,代码行数:24,代码来源:CryptBlowfish.php

示例7: encryptText

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

示例8: blowfishEncode

/**
 * Uses blowfish to encrypt data and base 64 encodes it. It stores the iv as part of the data
 * @param STRING key - key to base encoding off of
 * @param STRING data - string to be encrypted and encoded
 * @return string
 */
function blowfishEncode($key, $data)
{
    $bf = new Crypt_Blowfish($key);
    $encrypted = $bf->encrypt($data);
    return base64_encode($encrypted);
}
开发者ID:sysraj86,项目名称:carnivalcrm,代码行数:12,代码来源:encryption_utils.php

示例9: modifyAccountNow

 /**
  * modifyAccountNow 
  * 
  * Modify Acount
  * 
  * @access public
  * @return void
  */
 public function modifyAccountNow()
 {
     // Make sure account was supplied
     if (!isset($_REQUEST['account'])) {
         throw new Framework_Exception(_("Error: no account supplied"));
     }
     $account = $_REQUEST['account'];
     // See what user_info to use
     if ($this->user->isDomainAdmin($this->domain)) {
         $account_info = $this->user->userInfo($this->domain, $account);
     } else {
         $account_info = $this->user->loginUser;
     }
     // Get .qmail info if it exists
     try {
         $dot_qmail = $this->user->readFile($this->domain, $_REQUEST['account'], '.qmail');
     } catch (Net_Vpopmaild_Exception $e) {
         $dot_qmail = '';
     }
     $defs = $this->parseHomeDotqmail($dot_qmail, $account_info);
     $form = $this->modifyAccountForm($account, $defs);
     if (!$form->validate()) {
         $this->setData('message', _("Error Modifying Account"));
         $renderer =& new HTML_QuickForm_Renderer_AssocArray();
         $form->accept($renderer);
         $this->setData('form', $renderer->toAssocArray());
         $this->tplFile = 'modifyAccount.tpl';
         return;
     }
     // update password / comment if it's changing
     $changePass = 0;
     $changeComment = 0;
     $password = $form->getElementValue('password');
     $comment = $form->getElementValue('comment');
     if (!empty($password)) {
         $account_info['clear_text_password'] = $password;
         $changePass = 1;
     }
     if (!empty($comment)) {
         $account_info['comment'] = $comment;
     }
     if ($changePass || $changeComment) {
         $this->user->modUser($this->domain, $_REQUEST['account'], $account_info);
     }
     if ($changePass && $account == $this->user->loginUser['name'] && $this->domain == $this->user->loginUser['domain']) {
         $crypt = new Crypt_Blowfish((string) Framework::$site->config->mcryptKey);
         $this->session->password = $crypt->encrypt($password);
     }
     // Determine new routing
     $routing = '';
     $save_a_copy = 0;
     if ($_REQUEST['routing'] == 'routing_standard') {
         $routing = 'standard';
     } else {
         if ($_REQUEST['routing'] == 'routing_deleted') {
             $routing = 'deleted';
         } else {
             if ($_REQUEST['routing'] == 'routing_forwarded') {
                 if (empty($_REQUEST['forward'])) {
                     $this->setData('message', _('Error: you must supply a forward address'));
                     return $this->modifyAccount();
                 } else {
                     $forward = $_REQUEST['forward'];
                 }
                 $routing = 'forwarded';
                 if (isset($_REQUEST['save_a_copy'])) {
                     $save_a_copy = 1;
                 }
             } else {
                 $this->setData('message', _('Error: unsupported routing selection'));
                 return $this->modifyAccount();
             }
         }
     }
     // Check for vacation
     $vacation = 0;
     if (isset($_REQUEST['vacation']) && $_REQUEST['vacation'] == 1) {
         $vacation = 1;
         $vacation_subject = $_REQUEST['vacation_subject'];
         $vacation_body = $_REQUEST['vacation_body'];
     }
     // Are we deleting a vacation message?
     if ($vacation == 0 && $defs['vacation'] == ' checked') {
         // Kill old message
         $this->user->rmDir($this->domain, $account_info['name'], 'vacation');
     }
     // Build .qmail contents
     $dot_qmail_contents = '';
     if ($routing == 'deleted') {
         $dot_qmail_contents = "# delete";
     } else {
         if ($routing == 'forwarded') {
//.........这里部分代码省略.........
开发者ID:shupp,项目名称:toasteradmin,代码行数:101,代码来源:Modify.php

示例10: encrypt

 function encrypt($plaintext)
 {
     $ciphertext = '';
     $paddedtext = $this->maxi_pad($plaintext);
     $strlen = strlen($paddedtext);
     for ($x = 0; $x < $strlen; $x += 8) {
         $piece = substr($paddedtext, $x, 8);
         $cipher_piece = parent::encrypt($piece);
         $encoded = base64_encode($cipher_piece);
         $ciphertext = $ciphertext . $encoded;
     }
     return $ciphertext;
 }
开发者ID:vincent,项目名称:theinvertebrates,代码行数:13,代码来源:Blowfish.php

示例11: legacyEncrypt

 /**
  * @brief encryption using legacy blowfish method
  * @param $data string data to encrypt
  * @param $passwd string password
  * @return string
  */
 function legacyEncrypt($data, $passwd)
 {
     $bf = new \Crypt_Blowfish($passwd);
     $crypted = $bf->encrypt($data);
     return $crypted;
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:12,代码来源:crypt.php

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

示例13: extract

 /** Encrpytes a value using the blowfish cipher. As key the Security.salt
     * value is used 
     @param value Value to cipher
     @return Return of the chiphered value in base64 encoding. To distinguish
     ciphed value, the ciphed value has a prefix of '$E$' i
     @see _decryptValue(), _packValue(), _generateSalt() */
 function _encryptValue($value, $config)
 {
     extract($config);
     $bf = new Crypt_Blowfish($key);
     $enclose = $this->_packValue($value, $this->_generateSalt($value, $key, $saltLen), $padding);
     $encrypted = $bf->encrypt($enclose);
     if (PEAR::isError($encrypted)) {
         $this->log($encrypted->getMessage());
         return false;
     }
     return $prefix . base64_encode($encrypted);
 }
开发者ID:studdr,项目名称:cakephp-extras,代码行数:18,代码来源:cipher.php

示例14: generateRequest

 /**
  * Uses blowfish to encrypt data and base 64 encodes it. It stores the iv as part of the data
  * @param string key - key to base encoding off of
  * @param string data - string to be encrypted and encoded
  * @param object Crypt_Blowfish object
  * @return string
  */
 public function generateRequest($key, $data, $bf = null)
 {
     if (!$bf) {
         // @codeCoverageIgnoreStart
         $bf = new Crypt_Blowfish($key);
     }
     // @codeCoverageIgnoreEnd
     $encrypted = $bf->encrypt($data);
     $encrypted = base64_encode($encrypted);
     $output = "----- BEGIN LICENSE REQUEST -----\n";
     $i = 0;
     $len = strlen($encrypted);
     while ($i + 80 < $len) {
         $output .= substr($encrypted, $i, 80) . "\n";
         $i += 80;
     }
     $output .= substr($encrypted, $i) . "\n";
     $output .= "----- END LICENSE REQUEST -----\n";
     return $output;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:27,代码来源:Crypt.php

示例15: setcookie

// PEAR.
ini_set('include_path', BABEL_PREFIX . '/libs/pear' . PATH_SEPARATOR . ini_get('include_path'));
require_once 'Crypt/Blowfish.php';
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
    $db = mysql_connect(BABEL_DB_HOSTNAME . ':' . BABEL_DB_PORT, BABEL_DB_USERNAME, BABEL_DB_PASSWORD);
    if ($db) {
        mysql_select_db(BABEL_DB_SCHEMATA);
        mysql_query("SET NAMES utf8");
        mysql_query("SET CHARACTER SET utf8");
        mysql_query("SET COLLATION_CONNECTION='utf8_general_ci'");
    }
    $rt = vx_check_login();
    if ($rt['errors'] == 0) {
        $bf = new Crypt_Blowfish(BABEL_BLOWFISH_KEY);
        setcookie('babel_usr_email', $rt['usr_email_value'], time() + 2678400, '/', BABEL_DNS_DOMAIN);
        setcookie('babel_usr_password', $bf->encrypt(sha1($rt['usr_password_value'])), time() + 2678400, '/', BABEL_DNS_DOMAIN);
        $_SESSION['babel_usr_email'] = $rt['usr_email_value'];
        $_SESSION['babel_usr_password'] = sha1($rt['usr_password_value']);
        $rt['mode'] = 'ok';
        if (trim($rt['return']) != '') {
            if (preg_match('/logout/i', $rt['return'])) {
                header('Location: /');
                die;
            } else {
                header('Location: ' . $rt['return']);
                die;
            }
        }
    } else {
        $rt['mode'] = 'error';
    }
开发者ID:biaodianfu,项目名称:project-babel,代码行数:31,代码来源:login.php


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