PHP code example of bestyii / yii2-encrypter

1. Go to this page and download the library: Download bestyii/yii2-encrypter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bestyii / yii2-encrypter example snippets


return [
    //...
    'components' => [
        //...
        'encrypter' => [
            'class' => 'bestyii\encrypter\Encrypter',
            'key' => '32bit string',
            'iv' => '32bit string',
        ],
    ],
];

\Yii::$app->encrypter->encrypt('string to encrypt');

\Yii::$app->encrypter->decrypt('string to decrypt');

public function behaviors()
{
    return [
        'encryption' => [
            'class' => '\bestyii\encrypter\EncrypterBehavior',
            'attributes' => [
                'attributeName',
                'otherAttributeName',
            ],
        ],
    ];
}

php composer.phar