mazfreelance/yii2-laravel-crypt

This package is abandoned and no longer maintained. No replacement package was suggested.

yii2-laravel-crypt is yii2 library compatiable with laravel

v1.1.4 2021-12-08 10:32 UTC

This package is auto-updated.

Last update: 2023-08-08 14:36:11 UTC


README

this is same as laravel(>=5.1) encrypt and decrypt function.

Changelog

For changes since the last version see the Changelog.

Installation

composer require mazfreelance/yii2-laravel-crypt -W

Config

add your params local

'encrypter' => [
    'key' = '',
    'cipher' = ''
]

Usage:

1) single use OR

use Cryption\Encrypter;

$cryption = Encrypter("yourRandomString","AES-256-CBC");
$cryption->encrypt("yourData");`

2) this Behavior is used to encrypt data before storing it on the database and to decrypt it upon retrieval.

  • add the following code on Model class
public function behaviors()
{
    return [
        'encryption' => [
            'class' => '\Cryption\EncryptionBehavior',
            'attributes' => [
                'attribute1',
                'attribute2',
            ],
        ],
    ];
}