use \PSL\Encrypter;
$confidentalText = 'I am using PSL';
$cipherText = Encrypter::encrypt(MCRYPT_RIJNDAEL_256, $confidentalText);
// $cipherText is an instance of \PSL\CipherText.
// To extract, do something like this:
$key = $cipherText->key;
$plainText = Encrypter::decrypt($cipherText, $key);
// $plainText is now same as $confidentalText.
Lessons Learned:
- Do not store the key in the ciphertext.
- Design APIs so that it is as difficult as possible to use them incorrectly.
No comments:
Post a Comment