本文整理汇总了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;
}
示例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();
}
示例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;
}
示例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());
}
}
示例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;
}
示例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() );
}
示例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';
}
示例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));
}
示例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"]};
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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 .= '
//.........这里部分代码省略.........
示例15: decryptText
function decryptText($text)
{
require_once 'Crypt/Blowfish.php';
$bf = new Crypt_Blowfish(ENCRYPTKEY);
$plaintext = $bf->decrypt(convertString(trim($text)));
return trim($plaintext);
}