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/clone/wp-conte.../plugins/flow-flo.../libs/cakephp/utility/Crypto
File: Mcrypt.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
/**
[16] Fix | Delete
* Mcrypt implementation of crypto features for Cake\Utility\Security
[17] Fix | Delete
*
[18] Fix | Delete
* This class is not intended to be used directly and should only
[19] Fix | Delete
* be used in the context of Cake\Utility\Security.
[20] Fix | Delete
*
[21] Fix | Delete
* @deprecated 3.3.0 It is recommended to use {@see \Cake\Utility\Crypto\OpenSsl} instead.
[22] Fix | Delete
* @internal
[23] Fix | Delete
*/
[24] Fix | Delete
class Mcrypt
[25] Fix | Delete
{
[26] Fix | Delete
/**
[27] Fix | Delete
* Encrypts/Decrypts a text using the given key using rijndael method.
[28] Fix | Delete
*
[29] Fix | Delete
* @param string $text Encrypted string to decrypt, normal string to encrypt
[30] Fix | Delete
* @param string $key Key to use as the encryption key for encrypted data.
[31] Fix | Delete
* @param string $operation Operation to perform, encrypt or decrypt
[32] Fix | Delete
* @throws \LogicException When there are errors.
[33] Fix | Delete
* @return string Encrypted binary string data, or decrypted data depending on operation.
[34] Fix | Delete
* @deprecated 3.3.0 This method will be removed in 4.0.0.
[35] Fix | Delete
*/
[36] Fix | Delete
public static function rijndael($text, $key, $operation)
[37] Fix | Delete
{
[38] Fix | Delete
$algorithm = MCRYPT_RIJNDAEL_256;
[39] Fix | Delete
$mode = MCRYPT_MODE_CBC;
[40] Fix | Delete
$ivSize = mcrypt_get_iv_size($algorithm, $mode);
[41] Fix | Delete
[42] Fix | Delete
$cryptKey = mb_substr($key, 0, 32, '8bit');
[43] Fix | Delete
[44] Fix | Delete
if ($operation === 'encrypt') {
[45] Fix | Delete
$iv = mcrypt_create_iv($ivSize, MCRYPT_DEV_URANDOM);
[46] Fix | Delete
[47] Fix | Delete
return $iv . '$$' . mcrypt_encrypt($algorithm, $cryptKey, $text, $mode, $iv);
[48] Fix | Delete
}
[49] Fix | Delete
$iv = mb_substr($text, 0, $ivSize, '8bit');
[50] Fix | Delete
$text = mb_substr($text, $ivSize + 2, null, '8bit');
[51] Fix | Delete
[52] Fix | Delete
return rtrim(mcrypt_decrypt($algorithm, $cryptKey, $text, $mode, $iv), "\0");
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
/**
[56] Fix | Delete
* Encrypt a value using AES-256.
[57] Fix | Delete
*
[58] Fix | Delete
* *Caveat* You cannot properly encrypt/decrypt data with trailing null bytes.
[59] Fix | Delete
* Any trailing null bytes will be removed on decryption due to how PHP pads messages
[60] Fix | Delete
* with nulls prior to encryption.
[61] Fix | Delete
*
[62] Fix | Delete
* @param string $plain The value to encrypt.
[63] Fix | Delete
* @param string $key The 256 bit/32 byte key to use as a cipher key.
[64] Fix | Delete
* @return string Encrypted data.
[65] Fix | Delete
* @throws \InvalidArgumentException On invalid data or key.
[66] Fix | Delete
* @deprecated 3.3.0 Use Cake\Utility\Crypto\OpenSsl::encrypt() instead.
[67] Fix | Delete
*/
[68] Fix | Delete
public static function encrypt($plain, $key)
[69] Fix | Delete
{
[70] Fix | Delete
deprecationWarning(
[71] Fix | Delete
'Mcrypt::encrypt() is deprecated. ' .
[72] Fix | Delete
'Use Cake\Utility\Crypto\OpenSsl::encrypt() instead.'
[73] Fix | Delete
);
[74] Fix | Delete
$algorithm = MCRYPT_RIJNDAEL_128;
[75] Fix | Delete
$mode = MCRYPT_MODE_CBC;
[76] Fix | Delete
[77] Fix | Delete
$ivSize = mcrypt_get_iv_size($algorithm, $mode);
[78] Fix | Delete
$iv = mcrypt_create_iv($ivSize, MCRYPT_DEV_URANDOM);
[79] Fix | Delete
[80] Fix | Delete
// Pad out plain to make it AES compatible.
[81] Fix | Delete
$pad = ($ivSize - (mb_strlen($plain, '8bit') % $ivSize));
[82] Fix | Delete
$plain .= str_repeat(chr($pad), $pad);
[83] Fix | Delete
[84] Fix | Delete
return $iv . mcrypt_encrypt($algorithm, $key, $plain, $mode, $iv);
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* Decrypt a value using AES-256.
[89] Fix | Delete
*
[90] Fix | Delete
* @param string $cipher The ciphertext to decrypt.
[91] Fix | Delete
* @param string $key The 256 bit/32 byte key to use as a cipher key.
[92] Fix | Delete
* @return string Decrypted data. Any trailing null bytes will be removed.
[93] Fix | Delete
* @throws \InvalidArgumentException On invalid data or key.
[94] Fix | Delete
* @deprecated 3.3.0 Use Cake\Utility\Crypto\OpenSsl::decrypt() instead.
[95] Fix | Delete
*/
[96] Fix | Delete
public static function decrypt($cipher, $key)
[97] Fix | Delete
{
[98] Fix | Delete
deprecationWarning(
[99] Fix | Delete
'Mcrypt::decrypt() is deprecated. ' .
[100] Fix | Delete
'Use Cake\Utility\Crypto\OpenSsl::decrypt() instead.'
[101] Fix | Delete
);
[102] Fix | Delete
$algorithm = MCRYPT_RIJNDAEL_128;
[103] Fix | Delete
$mode = MCRYPT_MODE_CBC;
[104] Fix | Delete
$ivSize = mcrypt_get_iv_size($algorithm, $mode);
[105] Fix | Delete
[106] Fix | Delete
$iv = mb_substr($cipher, 0, $ivSize, '8bit');
[107] Fix | Delete
$cipher = mb_substr($cipher, $ivSize, null, '8bit');
[108] Fix | Delete
$plain = mcrypt_decrypt($algorithm, $key, $cipher, $mode, $iv);
[109] Fix | Delete
[110] Fix | Delete
// Remove PKCS#7 padding or Null bytes
[111] Fix | Delete
// Newer values will be PKCS#7 padded, while old
[112] Fix | Delete
// mcrypt values will be null byte padded.
[113] Fix | Delete
$padChar = mb_substr($plain, -1, null, '8bit');
[114] Fix | Delete
if ($padChar === "\0") {
[115] Fix | Delete
return trim($plain, "\0");
[116] Fix | Delete
}
[117] Fix | Delete
$padLen = ord($padChar);
[118] Fix | Delete
$result = mb_substr($plain, 0, -$padLen, '8bit');
[119] Fix | Delete
[120] Fix | Delete
return $result === '' ? false : $result;
[121] Fix | Delete
}
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function