/** * @param $text * @return string */ public function encrypt($text) { $encrypted = $this->mcrypt($this->stringFormatter->prepareString($text)); $result = rtrim(base64_encode($encrypted), '=') . $this->key->getRandomHexadecimalPosition() . $this->IV->getRandomHexadecimalPosition(); $this->resetCurrentProcess(); return $result; }
/** * @param $encrypted_text * @return string */ public function decrypt($encrypted_text) { $this->IV->setHexadecimalPosition(substr($encrypted_text, -2)); $this->key->setHexadecimalPosition(substr($encrypted_text, -4, 2)); $encrypted_text = base64_decode(substr($encrypted_text, 0, -4)); $decrypted = $this->mdecrypt($encrypted_text); $this->resetCurrentProcess(); return $this->stringFormatter->cleanString($decrypted); }