About RSA+AES encryption (how to decrypt AES in PHP)

Today, I tried to encrypt and transmit the password submitted by the user through the RSA+AES method. I have completed the writing of the front-end JS (with a screenshot of the run result, the value of AES,RSA encryption will change). It uses two libraries, namely and crypto-js . Now, I am writing the back-end decryption PHP (the code is as follows), but I have encountered a little difficulty in the process, the RSA decryption part has been written and tested correctly, but I do not know how to write the AES decryption part, even though I have looked up a lot of data, their examples are a little different from mine, I do not know how to use it (I will attach some examples at the end of the article).
question:
1, is my JS encrypted part correct and logical;
2, how should I write the PHP AES decryption part;
3, is my thinking correct? :
client (JavaScript):
AES encryption original user password
RSA public key encryption AES key
-- data transfer--
server (PHP):
RSA private key decryption obtains AES secret key
AES decryption obtains original user password
then encrypts the original user password and stores the encrypted user password in the database
my JavaScript Code:

$(function () {
            //
            //AES
            var password_form="QAQ";
            console.log(password_form);
            var password = CryptoJS.AES.encrypt(password_form,"Lime Website").toString();
            console.log(password);
            //RSA
            var public_key = $("-sharpinputPublic_key").val();
            console.log(public_key);
            var private_key = $("-sharpinputPrivate_key").val();
            console.log(private_key);
            var encrypt = new JSEncrypt();
            encrypt.setPublicKey(public_key);
            var AES_key = encrypt.encrypt(password);
            console.log(AES_key);
            
            //
            //RSA
            var decrypt = new JSEncrypt();
            decrypt.setPrivateKey(private_key);
            var AES_key_decrypt = decrypt.decrypt(AES_key);
            console.log(AES_key_decrypt);
            //AES
            var bytes = CryptoJS.AES.decrypt(AES_key_decrypt,"Lime Website");
            var password_decrypt = bytes.toString(CryptoJS.enc.Utf8);
            console.log(password_decrypt);
        });

my PHP code:

<?php
$private_key = "-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDlOJu6TyygqxfWT7eLtGDwajtNFOb9I5XRb6khyfD1Yt3YiCgQ
WMNW649887VGJiGr/L5i2osbl8C9+WJTeucF+S76xFxdU6jE0NQ+Z+zEdhUTooNR
aY5nZiu5PgDB0ED/ZKBUSLKL7eibMxZtMlUDHjm4gwQco1KRMDSmXSMkDwIDAQAB
AoGAfY9LpnuWK5Bs50UVep5c93SJdUi82u7yMx4iHFMc/Z2hfenfYEzu+57fI4fv
xTQ//5DbzRR/XKb8ulNv6+CHyPF31xk7YOBfkGI8qjLoq06V+FyBfDSwL8KbLyeH
m7KUZnLNQbk8yGLzB3iYKkRHlmUanQGaNMIJziWOkN+N9dECQQD0ONYRNZeuM8zd
8XJTSdcIX4a3gy3GGCJxOzv16XHxD03GW6UNLmfPwenKu+cdrQeaqEixrCejXdAF
z/7+BSMpAkEA8EaSOeP5Xr3ZrbiKzi6TGMwHMvC7HdJxaBJbVRfApFrE0/mPwmP5
rN7QwjrMY+0+AbXcm8mRQyQ1+IGEembsdwJBAN6az8Rv7QnD/YBvi52POIlRSSIM
V7SwWvSK4WSMnGb1ZBbhgdg57DXaspcwHsFV7hByQ5BvMtIduHcT14ECfcECQATe
aTgjFnqE/lQ22Rk0eGaYO80cc643BXVGafNfd9fcvwBMnk0iGX0XRsOozVt5Azil
psLBYuApa66NcVHJpCECQQDTjI2AQhFc1yRnCU/YgDnSpJVm1nASoRUnU8Jfm3Oz
uku7JUXcVpt08DFSceCEX9unCuMcT72rAQlLpdZir876
-----END RSA PRIVATE KEY-----";
$private_key_public_key_availability = openssl_pkey_get_private($private_key);//id Resource id
$AES_key = "iOks+yhKxQBiqtd5rHQRNdXOGqixhNzquuZuPZ5dDsYfh1nDTLiygukiyexNBqHfmA7zis1nRTZW2Nw4bN5Pr2yCgvh1GPV6K5WigO5jD1+ztuyp1hV5ymNSws6EUPPjW9cwrOpO7EIeiYjvGo7ziyPwsCU0vwtQAkNAFY3uhB0=";
$AES_key_decrypted = ""; 
echo ":";
openssl_private_decrypt(base64_decode($AES_key),$AES_key_decrypted,$private_key_public_key_availability);
echo $AES_key_decrypted;

screenshot of one run result of JavaScript:

some examples:
https://odan.github.io/2017/0...
https://stackoverflow.com/ Que...
https://stackoverflow.com/que...
finally thank you for your answers QAQ

Jun.08,2022

CryptoJS automatically adopts the scheme when using AES without specifying an encryption mode.

https://stackoverrun.com/cn/q...

decryption and writing reference

https://github.com/etienne-ma...

during the development process, we should always strictly , explicitly specify the encryption mode , fill . You should also adjust the filling method used

according to the background language.
Menu