- var_dump: documentation ( source)
- chr: documentation ( source)
- str_repeat: documentation ( source)
- base64_encode: documentation ( source)
<?php
$secret = 'a0a7e7997b6d5fcd55f4b5c32611b87c';
function encrypt128($str, $secret)
{
$block = 16;
$pad = $block - (strlen($str) % $block);
$str .= str_repeat(chr($pad), $pad);
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $secret, $str, MCRYPT_MODE_ECB));
}
var_dump(encrypt128('small1', $secret));