Are there any specific limitations or considerations when using openssl_encrypt with single-word inputs in PHP?

When using openssl_encrypt with single-word inputs in PHP, you need to ensure that the input is converted to a byte string before encryption. This is because openssl_encrypt expects a byte string as input, and single-word inputs may not be interpreted correctly. To solve this, you can use the mb_convert_encoding function to convert the input to a byte string before encryption.

$input = "example";
$input = mb_convert_encoding($input, 'UTF-8');
$method = 'AES-256-CBC';
$key = openssl_random_pseudo_bytes(32);
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($method));
$encrypted = openssl_encrypt($input, $method, $key, OPENSSL_RAW_DATA, $iv);