/** * @return McryptContainer */ public function getContainer() { $container = new McryptContainer(); $container->setData($this->data); $container->setPasswordSalt($this->passwordSalt); $container->setInitializationVector($this->initializationVector); $container->setCipher($this->cipher); return $container; }
/** * Encrypts the data with the given key. * * @param string $data * @param string $key * @return McryptContainer */ public function encrypt($data, $key) { $container = new McryptContainer(); $container->setInitializationVector($this->getInitializationVector()); $container->setPasswordSalt($this->generateSalt()); $container->setCipher($this->cipher); $container->setData(mcrypt_encrypt($this->cipher, $this->getKeyHash($key, $container->getPasswordSalt()), sha1($data) . $data, $this->mode, $container->getInitializationVector())); return $container; }