- hash_hmac: documentation ( source)
- str_repeat: documentation ( source)
- hash: documentation ( source)
- base64_encode: documentation ( source)
<?php
$cipher = openssl_encrypt(
'Yes, it totally does.',
'aes-128-ctr',
hash('sha256', 'spottycats', true),
OPENSSL_RAW_DATA,
str_repeat("\x00", 16)
);
$hmac = hash_hmac(
'sha256',
$cipher,
hash('sha256', 'spottycats', true),
true
);
echo base64_encode($cipher . $hmac), PHP_EOL;