本文整理汇总了PHP中JCrypt::setKey方法的典型用法代码示例。如果您正苦于以下问题:PHP JCrypt::setKey方法的具体用法?PHP JCrypt::setKey怎么用?PHP JCrypt::setKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JCrypt
的用法示例。
在下文中一共展示了JCrypt::setKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCrypt
/**
*
* @return \JCrypt
*/
private static function getCrypt()
{
$crypt = new JCrypt();
$conf = JFactory::getConfig();
$key = new JCryptKey('simple');
$key->private = $conf->get('secret');
$key->public = $key->private;
$crypt->setKey($key);
return $crypt;
}
示例2: getCrypt
/**
* Setups the JCrypt object with default keys if not specified then returns it.
*
* @param array $options Optional override options for keys.
*
* @return JCrypt The configured JCrypt object.
*
* @since 2.0
*/
public static function getCrypt($options = array())
{
$source = strtolower(JArrayHelper::getValue($options, 'source', 'jconfig', 'string'));
if ($source === 'jconfig') {
/*
* If JConfig has been included then lets check whether the keys
* have been imported and if not then use the secret value for now.
*/
if (class_exists('JConfig')) {
$config = new JConfig();
if (!isset($options['key'])) {
$options['key'] = $config->secret;
}
}
} elseif ($source === 'file') {
$file = JArrayHelper::getValue($options, 'file', '', 'string');
if (file_exists($file)) {
$options['key'] = file_get_contents($file);
}
}
$crypt = new JCrypt();
// Create some default options
$type = JArrayHelper::getValue($options, 'type', 'simple', 'string');
$key = JArrayHelper::getValue($options, 'key', 'DEFAULTKEY', 'string');
$crypt->setKey(new JCryptKey($type, $key, $key));
return $crypt;
}