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/wordfenc.../modules/login-se.../classes/model/crypto
File: symmetric.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace WordfenceLS\Crypto;
[2] Fix | Delete
[3] Fix | Delete
use WordfenceLS\Model_Crypto;
[4] Fix | Delete
[5] Fix | Delete
abstract class Model_Symmetric {
[6] Fix | Delete
/**
[7] Fix | Delete
* Returns $data encrypted with the shared symmetric key or false if unable to do so.
[8] Fix | Delete
*
[9] Fix | Delete
* @param string $data
[10] Fix | Delete
* @return bool|array
[11] Fix | Delete
*/
[12] Fix | Delete
public static function encrypt($data) {
[13] Fix | Delete
if (!Model_Crypto::has_required_crypto_functions()) {
[14] Fix | Delete
return false;
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
$symmetricKey = Model_Crypto::shared_symmetric_secret();
[18] Fix | Delete
$iv = Model_Crypto::random_bytes(16);
[19] Fix | Delete
$encrypted = @openssl_encrypt($data, 'aes-256-cbc', $symmetricKey, OPENSSL_RAW_DATA, $iv);
[20] Fix | Delete
if ($encrypted) {
[21] Fix | Delete
return array('data' => base64_encode($encrypted), 'iv' => base64_encode($iv));
[22] Fix | Delete
}
[23] Fix | Delete
return false;
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* Returns the decrypted value of a payload encrypted by Model_Symmetric::encrypt
[28] Fix | Delete
*
[29] Fix | Delete
* @param array $encrypted
[30] Fix | Delete
* @return bool|string
[31] Fix | Delete
*/
[32] Fix | Delete
public static function decrypt($encrypted) {
[33] Fix | Delete
if (!Model_Crypto::has_required_crypto_functions()) {
[34] Fix | Delete
return false;
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
if (!isset($encrypted['data']) || !isset($encrypted['iv'])) {
[38] Fix | Delete
return false;
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
$symmetricKey = Model_Crypto::shared_symmetric_secret();
[42] Fix | Delete
$iv = base64_decode($encrypted['iv']);
[43] Fix | Delete
$encrypted = base64_decode($encrypted['data']);
[44] Fix | Delete
$data = @openssl_decrypt($encrypted, 'aes-256-cbc', $symmetricKey, OPENSSL_RAW_DATA, $iv);
[45] Fix | Delete
return $data;
[46] Fix | Delete
}
[47] Fix | Delete
}
[48] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function