brainfoolong/cryptojs-aes-php — reverse-engineered prompt

Reverse engineered prompt

GitHub

Build me a small encryption library that lets a website encrypt a value in the browser with JavaScript and decrypt it later in PHP, or do the reverse. I want it to handle normal strings as well as arrays or objects by turning them into JSON, and the encrypted output should include the ciphertext, iv, and salt in a JSON format that both sides understand.

Use AES 256 CBC with random salt and random initialization vector, and make the PHP side work as a simple class people can include or install with Composer. Also include browser ready JavaScript files and a simple HTML example showing encrypt and decrypt in the console.

Please add clear examples for PHP only, JavaScript only, and mixed PHP to JavaScript usage. Include basic tests that prove something encrypted in PHP can be decrypted in JavaScript and something encrypted in JavaScript can be decrypted in PHP. Keep it compatible with PHP 7 and 8, and mention any important security notes or limitations in the README.

Want more depth? Deep Reverse