- var_dump: documentation ( source)
- bin2hex: documentation ( source)
- str_repeat: documentation ( source)
<?php
function insecureEncryptDoNotUse(string $plaintext, string $key): string
{
return \bin2hex(
\openssl_encrypt(
$plaintext,
'aes-128-ecb',
$key,
OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING
)
);
}
$key = str_repeat("3.14", 4);
var_dump(insecureEncryptDoNotUse('YELLOW SUBMARINE', $key));
var_dump(insecureEncryptDoNotUse('ORANGE SUBMARINE', $key));
var_dump(insecureEncryptDoNotUse('YELLOW SUBMARINE' . 'ORANGE SUBMARINE', $key));