How PHP decrypts AES

my JavaScript encryption code (using crypto-js ):

            var password_form="QAQ";
            console.log(password_form);
            var password = CryptoJS.AES.encrypt(password_form,"Lime Website").toString();
            console.log(password);

after password is transferred to the backend, how should I decrypt it through PHP?

Jun.10,2022

Let me add a few more points to the answer upstairs
first of all, aes is a symmetric encryption and there are many

encryption methods.

of course, there's more I just didn't truncate. Of course, the most commonly used one is aes-128-cbc
_
I don't understand js, but from your above code, your encrypted key is "Lime Website", which is only 12 bytes, which is only 12 bytes, which is only 12 bytes. I don't see from your js which encryption method is used, but it should be aes-128-cbc because of your js. There is no iv tag in the decryption process, and then the bytes do not exceed 128bytes

.

finally, I will attach my slightly more complete piece of code

$avaMethods = openssl_get_cipher_methods();
//
$method = 'aes-128-ecb';
if (!in_array($method, $avaMethods)) {
    exit('' . PHP_EOL);
}

$key = "";
$data = "";

$decData = openssl_decrypt($data, $method, $key, OPENSSL_RAW_DATA);
echo ":" . $decData . PHP_EOL;

php decryption code uses aes-128-cbc 's algorithm

$input = _POST('password');
$password = openssl_decrypt(base64_decode($input), 'AES-128-CBC', 'Lime website', OPENSSL_RAW_DATA,'');
echo $password;
Menu