src/Security/Encryption.php
public function decrypt($data)
    {
        $data = json_decode(base64_decode($data), true);

        $iv = base64_decode($data['iv']);

        if (!$this->isEncryptedDataValid($data)) {
            throw new Exception('The given encrypted data is invalid.');
        }
        if (!$this->isMacValid($data, 16)) {
            throw new Exception('The hash is invalid.');
        }
        /**
         * try to decrypt.
         */
        $decrypted = \openssl_decrypt(
            $data['value'], $this->cipher, $this->key, 0, $iv
        );

        /*
         * throw exception is we cannot decrypt
         */
        if ($decrypted === false) {
            throw new Exception('Data could not be decrypted.');
        }

        return $decrypted;
    }
public function decrypt($data)
    {
        $data = json_decode(base64_decode($data), true);

        $iv = base64_decode($data['iv']);

        if (!$this->isEncryptedDataValid($data)) {
            throw new Exception('The given encrypted data is invalid.');
        }
        if (!$this->isMacValid($data, 16)) {
            throw new Exception('The hash is invalid.');
        }
        /**
         * try to decrypt.
         */
        $decrypted = \openssl_decrypt(
            $data['value'], $this->cipher, $this->key, 0, $iv
        );

        /*
         * throw exception is we cannot decrypt
         */
        if ($decrypted === false) {
            throw new Exception('Data could not be decrypted.');
        }

        return $decrypted;
    }
public function decrypt ( $ data ) { $ data = json_decode ( base64_decode ( $ data ) , true ) ; $ iv = base64_decode ( $ data [ 'iv' ] ) ; if ( ! $ this -> isEncryptedDataValid ( $ data ) ) { throw new Exception ( 'The given encrypted data is invalid.' ) ; } if ( ! $ this -> isMacValid ( $ data , 16 ) ) { throw new Exception ( 'The hash is invalid.' ) ; } /**
         * try to decrypt.
         */ $ decrypted = \ openssl_decrypt ( $ data [ 'value' ] , $ this -> cipher , $ this -> key , 0 , $ iv ) ; /*
         * throw exception is we cannot decrypt
         */ if ( $ decrypted === false ) { throw new Exception ( 'Data could not be decrypted.' ) ; } return $ decrypted ; }
Decrypt the given data and return plain text.

@param $data

@throws Exception

@return string
Decrypt the given data and return plain text .