rafrsr/crypto

Easy encrypt and decrypt strings in PHP.

2.1.4 2019-09-12 16:53 UTC

This package is auto-updated.

Last update: 2024-04-13 02:45:50 UTC


README

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

Easy encrypt and decrypt strings in PHP.

Features

  • Easy usage Crypto::build('secretKey')->encrypt('secret message')
  • Support most populars MCRYPT algorithms
  • Encryption verification through the method isEncrypted($data)
  • Prevent double encryption/decryption

Usage

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