Easy encrypt and decrypt strings in PHP.
- Easy usage
Crypto::build('secretKey')->encrypt('secret message')
- Support most populars MCRYPT algorithms
- Encryption verification through the method
isEncrypted($data)
- Prevent double encryption/decryption
use Rafrsr\Crypto\Crypto;
$encryptor = Crypto::build('JH83UN177772JJASHGAGG38UABASDSD');
//$encryptor = Crypto::build('JH83UN177772JJASHGAGG38UABASDSD', MCRYPT_RIJNDAEL_128); //using specific algorithm
$secret = $encryptor->encrypt('This is a secret message');
if ($encryptor->isEncrypted($secret)) {
echo 'The messages is encrypted';
}
$notSecret = $encryptor->decrypt($secret);
if (!$encryptor->isEncrypted($notSecret)) {
echo 'The message is not encrypted';
}