本文整理汇总了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;
}