Encrypting/Decrypting data
The Yii2 framework contains a special security component that provides a set of methods for handling common security-related tasks. The \yii\base\Security
class requires the OpenSSL
PHP extension instead of mcrypt
.
Getting ready
- Create a new application by using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
- Set up the database connection and create a table named
order
, as follows:DROP TABLE IF EXISTS `order`; CREATE TABLE IF NOT EXISTS `order` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `client` VARCHAR(255) NOT NULL, `total` FLOAT NOT NULL, `encrypted_field` BLOB NOT NULL, PRIMARY KEY (`id`) );
- Generate an
Order
model using Gii. ...
Get Yii2 Application Development Cookbook - Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.