21 abstract class Base implements 31 $this->mcrypt = mcrypt_module_open(
32 constant(static::getAlgorithm()),
37 mcrypt_generic_init($this->mcrypt, $key, $iv);
40 final public function __destruct()
42 mcrypt_generic_deinit($this->mcrypt);
43 mcrypt_module_close($this->mcrypt);
48 if (!extension_loaded(
'mcrypt')) {
52 if (!defined(static::getAlgorithm())) {
55 $res = @mcrypt_module_open(
56 constant(static::getAlgorithm()),
62 mcrypt_module_close($res);
69 return mcrypt_get_iv_size(
70 constant(static::getAlgorithm()),
77 return mcrypt_get_block_size(
78 constant(static::getAlgorithm()),
83 final public function encrypt($seqno, $data)
85 return mcrypt_generic($this->mcrypt, $data);
88 final public function decrypt($seqno, $data)
90 return mdecrypt_generic($this->mcrypt, $data);
95 $algo = strtoupper(substr(strrchr(get_called_class(),
'\\'), 1));
96 return 'MCRYPT_' . $algo;
101 $cls = explode(
'\\', get_called_class());
102 $mode = strtolower($cls[count($cls) - 2]);
108 $algo = strtolower(substr(strrchr(get_called_class(),
'\\'), 1));
109 return $algo .
'-' . static::getMode();
static getName()
Return the name of the algorithm.
$mcrypt
mcrypt handle for the cipher.