title: Codeigniter decode not working
body: <p>I am making a little login system using php inside of Codeigniter framework. I using the encryption class to encode a password, store in database. Then on login, finds their encrypted password using their username, then matches it against the password they entered. The passwords ARE getting encoded during registration. And in the below code, I have been able to print out the encoded password from the database, but then it fails out whenever I run it through decode. But no error message, just nothing.</p>
  
  <pre><code>public function check_pw(){
      //post username and password to database
      $data['username'] = $this-&gt;input-&gt;post('username');
      $data['password'] = $this-&gt;input-&gt;post('password');
      $this-&gt;load-&gt;model('lindsdata');
      //encoded password returned from database - this is working
      $return_data = $this-&gt;lindsdata-&gt;password($data);
      //$return_data = $this-&gt;encrypt-&gt;decode($return_data);  
      //print_r shows $return_data does hold the encrypted password
      //but when I uncomment the line with decode in it, $return_data print_rs nothing. 
      print_r($return_data);
      if ($return_data == $data['password']) {
          redirect('/update/user', 'location');
      }
      if($return_data !== $data['password']){
          //at this point, $return_data of course still has nothing
          print_r($return_data);
          //print_r below is the entered password by user..that shows up.
          print_r($data['password']);
          $error['the_error'] = 'Your Credentials are wrong';
      }else{
          $error['the_error'] = '';
      }
  }
  </code></pre>
  
  <p>I tried this below to make sure things were being encoded properly...this returned "test" as expected.     </p>
  
  <pre><code> $a = "test";
   $test = $this-&gt;encrypt-&gt;encode($a); 
   $test = $this-&gt;encrypt-&gt;decode($test);
   print_r($test);
  </code></pre>
  
  <p>To further confuse me...I originally manually encoded a password (like in the code above) and had put the result in a database with a user (I had not set up a registration form yet, just did that so I had a user to work with)...that one works fine for some reason. None of the other encoded user passwords are working. I don't get why they are failing out during the decode. The database is set to varchar(255). And I am DEFINITELY getting the encoded password when I run it through decode...but then nothing. No error message or anything and very stumped. Thanks it advance. ...and I did not post the model because I don't think it was relevant since that is indeed returning the encoded password for checking as it should.        </p>
  
  <p>EDIT - It doesn't make sense $return_data is printing the hash from the DB and $password is returning the proper password but $pw is returning nothing. ...could it be that my SQL database is somehow corrupting/editing my hash? This should work from what I can tell.</p>
  
  <pre><code>    $data['username'] = $this-&gt;input-&gt;post('username');
      $password = $this-&gt;input-&gt;post('password');
      $this-&gt;load-&gt;model('lindsdata');
      $return_data = $this-&gt;lindsdata-&gt;password($data);
      print_r($return_data);
      print_r($password);
      $pw = password_verify($password, $return_data);
      print_r($pw);
  </code></pre>
  
  <p>EDIT - My input to the database is quite simple... I see no reason for that having an issue. ...still failing on either decode or password_verify. Still no idea the problem. It is a simple Mysql database...</p>
  
  <pre><code>public function register_submit(){
      $data['user_name'] = $this-&gt;input-&gt;post('user_name');
      $pwd = $this-&gt;input-&gt;post('password');
      $data['password'] =  password_hash($pwd, PASSWORD_DEFAULT);
      $this-&gt;load-&gt;model('lindsdata');
      $this-&gt;lindsdata-&gt;register($data);      
  }
  
  function register($data){
      $this-&gt;db-&gt;insert('cred', $data);
  }
  </code></pre>