<?php
echo bin2hex(
openssl_encrypt(
/* Message: */
"The quick brown fox jumps over the lazy dog",
/* Cipher algorithm and block mode: */
'aes-128-ctr',
/* Encryption key: (don't use weak keys like this ever, it's just an example!): */
"\x01\x02\x03\x04"."\x05\x06\x07\x08" . "\x09\x0a\x0b\x0c" . "\x0d\x0e\x0f\x10",
/* Constant that means "don't encode": */
OPENSSL_RAW_DATA,
/* Initialization Vector or Nonce -- don't ever actually use all NULL bytes: */
str_repeat("\0", 16)
// This is a really bad way to generate a nonce or IV.
// See how it's done here: http://stackoverflow.com/a/30189841/2224584
)
);
Fatal error: Uncaught Error: Call to undefined function openssl_encrypt() in /in/ih8om:4
Stack trace:
#0 {main}
thrown in /in/ih8om on line 4
Process exited with code 255.
Output for 7.0.0 - 7.0.18, 7.1.0 - 7.1.4
Fatal error: Uncaught Error: Call to undefined function openssl_encrypt() in /in/ih8om:3
Stack trace:
#0 {main}
thrown in /in/ih8om on line 3
Process exited with code 255.