/** * Sets the key. * * Rijndael supports five different key lengths, AES only supports three. * * @access public * @see \Topxia\Service\Util\Phpsec\Crypt\Rijndael:setKey() * @see setKeyLength() * * @param String $key */ public function setKey($key) { parent::setKey($key); if (!$this->explicit_key_length) { $length = strlen($key); switch (true) { case $length <= 16: $this->key_size = 16; break; case $length <= 24: $this->key_size = 24; break; default: $this->key_size = 32; } $this->_setEngine(); } }
private function decrypt($data, $key) { $decodeKey = base64_decode($key); $data = base64_decode($data); $iv = substr($decodeKey, 0, 16); $rijndael = new Rijndael(); $rijndael->setIV($iv); $rijndael->setKey($decodeKey); $rijndael->disablePadding(); $encrypted = $rijndael->decrypt($data); return $encrypted; }