本文整理汇总了PHP中Akeeba\Engine\Factory::getEncryption方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::getEncryption方法的具体用法?PHP Factory::getEncryption怎么用?PHP Factory::getEncryption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Akeeba\Engine\Factory
的用法示例。
在下文中一共展示了Factory::getEncryption方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getResponse
/**
* Packages the response to a JSON-encoded object, optionally encrypting the
* data part with a caller-supplied password.
*
* @return string The JSON-encoded response
*/
private function getResponse()
{
// Initialize the response
$response = array('encapsulation' => $this->encapsulation, 'body' => array('status' => $this->status, 'data' => null));
$data = json_encode($this->data);
if (empty($this->password)) {
$this->encapsulation = self::ENCAPSULATION_RAW;
}
switch ($this->encapsulation) {
case self::ENCAPSULATION_RAW:
break;
case self::ENCAPSULATION_AESCTR128:
$data = Factory::getEncryption()->AESEncryptCtr($data, $this->password, 128);
break;
case self::ENCAPSULATION_AESCTR256:
$data = Factory::getEncryption()->AESEncryptCtr($data, $this->password, 256);
break;
case self::ENCAPSULATION_AESCBC128:
$data = base64_encode(Factory::getEncryption()->AESEncryptCBC($data, $this->password, 128));
break;
case self::ENCAPSULATION_AESCBC256:
$data = base64_encode(Factory::getEncryption()->AESEncryptCBC($data, $this->password, 256));
break;
}
$response['body']['data'] = $data;
return '###' . json_encode($response) . '###';
}
示例2: encode
/**
* Encodes the data. The data is JSON encoded by this method before encapsulation takes place. Encrypted
* encapsulations will then encrypt the data and base64-encode it before returning it.
*
* The data being encoded correspond to the body > data structure described in the API documentation
*
* @param string $serverKey The server key we need to encode data
* @param mixed $data The data to encode, typically a string, array or object
*
* @return string The encapsulated data
*
* @see https://www.akeebabackup.com/documentation/json-api/ar01s02s02.html
*
* @throws \RuntimeException When the server capabilities don't match the requested encapsulation
* @throws \InvalidArgumentException When $data cannot be converted to JSON
*/
public function encode($serverKey, $data)
{
return Factory::getEncryption()->AESEncryptCtr($data, $serverKey, 128);
}
示例3: decryptSettings
/**
* Decrypts the encrypted settings and returns the plaintext INI string
*
* @param string $encrypted The encrypted data
*
* @return string The decrypted data
*/
public function decryptSettings($encrypted, $key = null)
{
if (substr($encrypted, 0, 12) == '###AES128###') {
$mode = 'AES128';
} elseif (substr($encrypted, 0, 12) == '###CTR128###') {
$mode = 'CTR128';
} else {
return $encrypted;
}
if (empty($key)) {
$key = $this->getKey();
}
$encrypted = substr($encrypted, 12);
switch ($mode) {
default:
case 'AES128':
$encrypted = base64_decode($encrypted);
$decrypted = Factory::getEncryption()->AESDecryptCBC($encrypted, $key, 128);
break;
case 'CTR128':
$decrypted = Factory::getEncryption()->AESDecryptCtr($encrypted, $key, 128);
break;
}
return $decrypted;
}
示例4: encode
/**
* Encodes the data. The data is JSON encoded by this method before encapsulation takes place. Encrypted
* encapsulations will then encrypt the data and base64-encode it before returning it.
*
* The data being encoded correspond to the body > data structure described in the API documentation
*
* @param string $serverKey The server key we need to encode data
* @param mixed $data The data to encode, typically a string, array or object
*
* @return string The encapsulated data
*
* @see https://www.akeebabackup.com/documentation/json-api/ar01s02s02.html
*
* @throws \RuntimeException When the server capabilities don't match the requested encapsulation
* @throws \InvalidArgumentException When $data cannot be converted to JSON
*/
public function encode($serverKey, $data)
{
return base64_encode(Factory::getEncryption()->AESEncryptCBC($data, $serverKey, 256));
}