加密/解密数据php

I'm trying to encrypt/decrypt data from a form.I took the class that helps me to do that from:

https://github.com/o/crypt-php

The encrypt works but when I try to decrypt it gives me an error saying that:

Uncaught exception 'Exception' with message 'The given data does not appear to be encrypted with Crypt'

My code:

  //for encrypt(this works)
  require_once("Crypt.php");

  $crypt = new Crypt;
  $crypt->setKey('keykeykeyy');
  $password = $_POST['password'];
  $crypt->setData($password);
  $encrypted = $crypt->encrypt();


  //for decrypt almost the same thing
  $password = $_POST['password'];
  $crypt->setData($password);
  $decrypted = $crypt->decrypt();

What's the problem?

The problem is this lines

  //for decrypt almost the same thing
  $password = $_POST['password'];
  $crypt->setData($password);
  $decrypted = $crypt->decrypt();

you are setting data for decrypt the raw password instead that you need pass as data the password encrypted

  $crypt->setData($encrypted);
  $decrypted = $crypt->decrypt();

regards