Tuesday, March 15, 2016

Re: Storing encrypted value using getter/setter not working. Stored in plain text.

When I try as follows, the value gets stored encryted, but I cannot read it as the getDecryptedUsername function returns false at the decrypt line:

protected function _setUsername($username)
{
 $key
= 'wt1U5MACWJFTXGenFoZoiLwQGrLgdbHA';
 
if(strlen($username) > 0)
 
{
 $username
= Security::encrypt($username, $key);
 
}
 
return($username);
}

protected function _getDecryptedUsername()
{
 $key
= 'wt1U5MACWJFTXGenFoZoiLwQGrLgdbHA';
 $username
= $this->_properties['username'];
 
if(strlen($username) > 0)
 
{
 $username
= Security::decrypt($username, $key);
 
}
 
return($username);
}

--
Sign up for our Newsletter for updates.
http://cakephp.org/newsletter/signup
 
We will soon be closing this Google Group. But don't worry, we have something better coming. Stay tuned for an updated from the CakePHP Team soon.
 
Like Us on FaceBook https://www.facebook.com/CakePHP
Follow us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: