Reputation: 1
So, i want to make an PHP extension by Zephir that can encrypt and encode a source code, but i have an error which is :
Error Message:
[ERROR] Returned values by functions can only be assigned to variant variables in
/home/ubuntu/ta/utils/utils/Cryptix.zep on line 15
Script zephir handling the __exec_command event returned with error code 1
Here is the Code:
Cryptix.zep
namespace Utils;
class Cryptix
{
/**
*
*
* @param string type
* @param string file
*
*/
public function encryptFile(type, file)
{
string code = file_get_contents(file, true);
string enc_code = "<?php Utils::decode('"+type+"', '"+openssl_enc(type, code)+"'); ?>";
file_put_contents(file + ".original", code);
file_put_contents(file, enc_code);
}
public function openssl_enc(string method, string data)
{
string firstkey = "Lk5Uz3slx3BrAghS1aaW5AYgWZRV0tIX5eI0yPchFz4=";
string secondkey = "EZ44mFi3TlAey1b2w4Y7lVDuqO+SRxGXsa7nctnr/JmMrA2vN6EJhrvdVZbxaQs5jpSe34X3ejFK/o9+Y5c83w==";
string first_key = base64_decode(firstkey);
string second_key = base64_decode(secondkey);
string iv_length = openssl_cipher_iv_length(method);
string iv = openssl_random_pseudo_bytes(iv_length);
string first_encrypted = openssl_encrypt(data, method, first_key, OPENSSL_RAW_DATA, iv);
string second_encrypted = hash_hmac("sha3-512", first_encrypted, second_key, true);
string output = base64_encode(iv + second_encrypted + first_encrypted);
return output;
}
}
what should i do to fix this error? thank you so much for your help.
Upvotes: 0
Views: 112