Easy encrypt and decrypt strings in PHP.

2.1.4 2019-09-12 16:53 UTC

This package is auto-updated.

Last update: 2020-08-12 19:23:02 UTC


Build Status Coverage Status Latest Stable Version Latest Unstable Version Total Downloads License

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';