Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/flow-flo.../libs/cakephp/utility/Crypto
File: OpenSsl.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
[2] Fix | Delete
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
[3] Fix | Delete
*
[4] Fix | Delete
* Licensed under The MIT License
[5] Fix | Delete
* For full copyright and license information, please see the LICENSE.txt
[6] Fix | Delete
* Redistributions of files must retain the above copyright notice.
[7] Fix | Delete
*
[8] Fix | Delete
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
[9] Fix | Delete
* @link https://cakephp.org CakePHP(tm) Project
[10] Fix | Delete
* @since 3.0.0
[11] Fix | Delete
* @license https://opensource.org/licenses/mit-license.php MIT License
[12] Fix | Delete
*/
[13] Fix | Delete
namespace Cake\Utility\Crypto;
[14] Fix | Delete
[15] Fix | Delete
use LogicException;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* OpenSSL implementation of crypto features for Cake\Utility\Security
[19] Fix | Delete
*
[20] Fix | Delete
* OpenSSL should be favored over mcrypt as it is actively maintained and
[21] Fix | Delete
* more widely available.
[22] Fix | Delete
*
[23] Fix | Delete
* This class is not intended to be used directly and should only
[24] Fix | Delete
* be used in the context of Cake\Utility\Security.
[25] Fix | Delete
*
[26] Fix | Delete
* @internal
[27] Fix | Delete
*/
[28] Fix | Delete
class OpenSsl
[29] Fix | Delete
{
[30] Fix | Delete
/**
[31] Fix | Delete
* @var string
[32] Fix | Delete
*/
[33] Fix | Delete
const METHOD_AES_256_CBC = 'aes-256-cbc';
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Not implemented
[37] Fix | Delete
*
[38] Fix | Delete
* @param string $text Encrypted string to decrypt, normal string to encrypt
[39] Fix | Delete
* @param string $key Key to use as the encryption key for encrypted data.
[40] Fix | Delete
* @param string $operation Operation to perform, encrypt or decrypt
[41] Fix | Delete
* @throws \LogicException Rijndael compatibility does not exist with Openssl.
[42] Fix | Delete
* @return void
[43] Fix | Delete
*/
[44] Fix | Delete
public static function rijndael($text, $key, $operation)
[45] Fix | Delete
{
[46] Fix | Delete
throw new LogicException('rijndael is not compatible with OpenSSL. Use mcrypt instead.');
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Encrypt a value using AES-256.
[51] Fix | Delete
*
[52] Fix | Delete
* *Caveat* You cannot properly encrypt/decrypt data with trailing null bytes.
[53] Fix | Delete
* Any trailing null bytes will be removed on decryption due to how PHP pads messages
[54] Fix | Delete
* with nulls prior to encryption.
[55] Fix | Delete
*
[56] Fix | Delete
* @param string $plain The value to encrypt.
[57] Fix | Delete
* @param string $key The 256 bit/32 byte key to use as a cipher key.
[58] Fix | Delete
* @return string Encrypted data.
[59] Fix | Delete
* @throws \InvalidArgumentException On invalid data or key.
[60] Fix | Delete
*/
[61] Fix | Delete
public static function encrypt($plain, $key)
[62] Fix | Delete
{
[63] Fix | Delete
$method = static::METHOD_AES_256_CBC;
[64] Fix | Delete
$ivSize = openssl_cipher_iv_length($method);
[65] Fix | Delete
[66] Fix | Delete
$iv = openssl_random_pseudo_bytes($ivSize);
[67] Fix | Delete
[68] Fix | Delete
return $iv . openssl_encrypt($plain, $method, $key, OPENSSL_RAW_DATA, $iv);
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* Decrypt a value using AES-256.
[73] Fix | Delete
*
[74] Fix | Delete
* @param string $cipher The ciphertext to decrypt.
[75] Fix | Delete
* @param string $key The 256 bit/32 byte key to use as a cipher key.
[76] Fix | Delete
* @return string Decrypted data. Any trailing null bytes will be removed.
[77] Fix | Delete
* @throws \InvalidArgumentException On invalid data or key.
[78] Fix | Delete
*/
[79] Fix | Delete
public static function decrypt($cipher, $key)
[80] Fix | Delete
{
[81] Fix | Delete
$method = static::METHOD_AES_256_CBC;
[82] Fix | Delete
$ivSize = openssl_cipher_iv_length($method);
[83] Fix | Delete
[84] Fix | Delete
$iv = mb_substr($cipher, 0, $ivSize, '8bit');
[85] Fix | Delete
[86] Fix | Delete
$cipher = mb_substr($cipher, $ivSize, null, '8bit');
[87] Fix | Delete
[88] Fix | Delete
return openssl_decrypt($cipher, $method, $key, OPENSSL_RAW_DATA, $iv);
[89] Fix | Delete
}
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function