Adil El Farissi
df8fe33007
Last cosmetics and PHP/LSL test scripts
All is working fine :)
The following script send a request to the PHP file where the encrypted string using osAESEncrypt() is decrypted and re-encrypted using the PHP openssl_XXXX. the return is the original string and the re-encrypted separated by "|"... the script decrypt the returned re-encrypted using osAESDecrypt() and log it in the chat.
LSL script:
<pre><code>
// Change the url to point to your PHP file.
string url = "http://127.0.0.1/aesTest.php";
string plainText = "Hello World :)";
string secret = "#!qUeRtY$@123^456€!#";
key r_id;
default
{
touch_start(integer i)
{
string encryptedText = osAESEncrypt(secret, plainText);
llOwnerSay("\nEncrypted with osAESEncrypt:\n"+ encryptedText);
r_id = llHTTPRequest(url, [HTTP_METHOD,"POST",HTTP_MIMETYPE,"application/x-www-form-urlencoded",HTTP_BODY_MAXLENGTH,"16384"], "data="+ encryptedText);
}
http_response(key id, integer status, list metaData, string Response){
if(status = 200 ){
if(id == r_id){
if(Response != ""){
list temp = llParseString2List(Response,"|",[]);
llOwnerSay("\nDecrypted using PHP openssl_decrypt:\n"+ llList2String(temp,0));
llOwnerSay("\nEncrypted using PHP openssl_encrypt:\n"+ llList2String(temp,1));
string decryptedText = osAESDecrypt(secret, llList2String(temp,1));
llOwnerSay("\nDecrypted with osAESDecrypt from PHP:\n"+ decryptedText);
}
else{
llOwnerSay("Enc/Dec Failed! Response:\n"+ Response);
}
}
}
else{
llOwnerSay("Destination not available.\nstatus: "+ status);
}
}
}
</code></pre>
The PHP file:
<pre><code>
<?php
if(getenv('REQUEST_METHOD') == 'POST') {
$script_data = file_get_contents("php://input");
if($script_data){
$data = $_POST['data'];
$secret = "#!qUeRtY$@123^456€!#";
$key = hex2bin(strtoupper(hash('sha256', $secret)));
$iv = hex2bin(strtoupper(explode(":", $data)[0]));
$encryptedText = hex2bin(strtoupper(explode(":", $data)[1]));
$plainText = openssl_decrypt($encryptedText, "AES-256-CBC", $key, $options=OPENSSL_RAW_DATA, $iv);
$retIv = openssl_random_pseudo_bytes(16);
$reEncrypted = openssl_encrypt($plainText, "AES-256-CBC", $key, $options=OPENSSL_RAW_DATA, $retIv);
echo $plainText && $reEncrypted ? $plainText."|".bin2hex($retIv).":".bin2hex($reEncrypted) : "";
}
};
?>
</code></pre>
Co-Authored-By: Ubit Umarov <469643+UbitUmarov@users.noreply.github.com>
2024-02-29 01:09:20 +00:00
..
2022-08-19 22:26:00 +01:00
2017-05-22 19:16:42 +01:00
2022-10-23 21:00:56 +01:00
2022-10-02 11:30:41 +01:00
2022-12-15 22:19:09 +00:00
2023-11-12 22:24:53 +00:00
2023-05-16 22:57:23 +01:00
2022-03-13 02:05:56 +00:00
2022-10-16 19:21:54 +01:00
2023-06-23 01:21:04 +01:00
2022-04-17 22:13:33 +01:00
2020-05-17 17:16:29 +01:00
2022-01-08 23:35:56 +00:00
2016-02-21 11:14:02 -08:00
2023-03-10 09:09:00 +00:00
2022-10-05 01:53:24 +01:00
2017-01-05 19:07:37 +00:00
2022-10-05 01:53:24 +01:00
2019-07-30 23:26:29 +01:00
2022-01-09 02:28:51 +00:00
2022-10-05 01:53:24 +01:00
2017-08-29 07:38:52 +01:00
2022-10-05 01:53:24 +01:00
2018-10-18 15:04:54 +01:00
2023-02-08 02:57:43 +00:00
2017-01-05 19:07:37 +00:00
2017-06-14 20:19:13 +01:00
2022-10-16 22:36:09 +01:00
2022-01-08 23:35:56 +00:00
2023-12-06 21:54:53 +00:00
2017-11-17 01:30:39 +00:00
2018-10-06 23:47:56 +01:00
2017-01-05 19:07:37 +00:00
2017-01-05 19:07:37 +00:00
2020-08-07 22:10:53 +01:00
2019-07-30 23:26:29 +01:00
2019-08-18 00:33:23 +01:00
2023-05-21 20:46:54 +01:00
2022-03-10 14:10:53 +00:00
2020-11-21 00:36:47 +00:00
2022-01-13 20:31:52 +00:00
2022-11-12 02:49:01 +00:00
2021-07-16 03:08:31 +01:00
2023-12-12 21:15:58 +00:00
2020-09-30 02:28:40 +01:00
2019-10-22 11:55:27 +01:00
2020-09-01 21:22:06 +01:00
2020-08-24 17:36:57 +01:00
2017-07-26 19:01:11 +01:00
2018-10-06 23:47:56 +01:00
2023-11-29 12:17:08 +00:00
2022-04-23 16:41:18 +01:00
2022-01-13 13:59:41 +00:00
2020-10-06 22:26:27 +01:00
2020-08-28 23:41:34 +01:00
2017-01-05 19:07:37 +00:00
2017-01-05 19:07:37 +00:00
2017-01-05 19:07:37 +00:00
2019-03-24 16:15:24 +00:00
2023-04-25 23:53:26 +01:00
2020-08-22 12:38:35 +01:00
2023-02-25 12:40:37 +00:00
2022-09-20 21:32:10 +01:00
2022-01-08 23:35:56 +00:00
2017-01-05 19:07:37 +00:00
2019-04-04 00:50:54 +01:00
2024-01-02 23:07:12 +00:00
2023-12-12 21:15:58 +00:00
2017-01-05 19:07:37 +00:00
2017-01-05 19:07:37 +00:00
2022-10-16 15:06:36 +01:00
2017-11-17 01:30:39 +00:00
2016-10-06 21:35:11 +01:00
2017-01-05 19:07:37 +00:00
2022-11-12 02:49:01 +00:00
2022-06-20 06:49:43 +01:00
2023-11-29 12:17:08 +00:00
2022-01-13 20:31:52 +00:00
2022-01-13 20:31:52 +00:00
2022-08-24 18:55:07 +01:00
2019-10-22 12:23:19 +01:00
2017-01-05 19:07:37 +00:00
2023-12-06 19:39:49 +00:00
2022-11-12 02:49:01 +00:00
2019-07-06 20:49:00 +01:00
2022-11-12 03:27:11 +00:00
2022-03-13 02:05:56 +00:00
2023-05-26 20:27:24 +01:00
2021-07-23 03:04:59 +01:00
2024-01-10 13:30:14 +00:00
2020-05-12 18:58:07 +01:00
2023-02-24 12:35:12 +00:00
2023-02-23 23:56:46 +00:00
2022-04-02 01:41:08 +01:00
2022-10-16 15:06:36 +01:00
2020-02-02 16:18:08 +00:00
2022-06-21 00:03:12 +01:00
2024-02-29 01:09:20 +00:00
2023-03-29 20:12:51 +01:00
2020-07-15 22:56:09 +01:00
2023-05-13 16:39:14 +01:00
2024-01-10 13:30:14 +00:00
2023-03-29 20:11:04 +01:00
2022-03-22 03:09:34 +00:00
2023-05-26 20:27:24 +01:00