本文整理匯總了PHP中Crypt_Blowfish::setKey方法的典型用法代碼示例。如果您正苦於以下問題:PHP Crypt_Blowfish::setKey方法的具體用法?PHP Crypt_Blowfish::setKey怎麽用?PHP Crypt_Blowfish::setKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Crypt_Blowfish
的用法示例。
在下文中一共展示了Crypt_Blowfish::setKey方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: strlen
function wrap_bp_decrypt($cipher_id, $key, $text, $iv)
{
$bf = new Crypt_Blowfish('cbc');
$iv_size = strlen($iv);
if ($iv_size !== false && $iv_size > 0) {
$bf->setKey($key, $iv);
} else {
$bf->setKey($key);
}
$text = $bf->decrypt($text);
if (PEAR::isError($text)) {
$last_bp_error = 'blowfish_decrypt_error ' . $text->getMessage();
return false;
}
$text = rtrim($text, "");
return $text;
}
示例2: __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;
}
示例3: decrypt
/**
*
*
* @param
* @return
*/
function decrypt($name, $encrypted_string)
{
if (!$name && !$encrypted_string) {
return $encrypted_string;
}
global $application;
$session_id = session_id();
$tables = $this->getTables();
$table = 'crypto_keys';
$k = $tables[$table]['columns'];
$query = new DB_Select();
$query->addSelectField($k["key"], "crypto_key");
$query->WhereValue($k["id"], DB_EQ, $session_id);
$query->WhereAnd();
$query->WhereValue($k["name"], DB_EQ, $name);
$result = $application->db->getDB_Result($query);
if (isset($result[0]['crypto_key']) && $result[0]['crypto_key']) {
$key = $result[0]['crypto_key'];
$query = new DB_Delete($table);
$query->WhereValue($k["id"], DB_EQ, $session_id);
$query->WhereAnd();
$query->WhereValue($k["name"], DB_EQ, $name);
$application->db->getDB_Result($query);
$blowfish = new Crypt_Blowfish($key);
$blowfish->setKey($key);
$string = $blowfish->decrypt($encrypted_string);
} else {
return "";
}
return $string;
}