2017 © Pedro Peláez
 

yii2-extension yii2-security

Yii2 extension for openssl encryption by public/private keys

image

miserenkov/yii2-security

Yii2 extension for openssl encryption by public/private keys

  • Wednesday, January 11, 2017
  • by miserenkov
  • Repository
  • 1 Watchers
  • 1 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Yii2 Security extension

Yii2 extension for encryption and decryption by openssl public/private keys, (*1)

License Latest Stable Version Latest Unstable Version Total Downloads Build Status Dependency Status , (*2)

Support

GitHub issues., (*3)

Installation

The preferred way to install this extension is through composer., (*4)

Either run, (*5)

php composer.phar require --prefer-dist miserenkov/yii2-security "^1.0"

or add, (*6)

"miserenkov/yii2-security": "^1.0"

to the require section of your composer.json file., (*7)

Configuration

To use security extension, you should configure it in the application configuration like the following, (*8)

'components' => [
    ...
    'security' => [
        'class' => 'miserenkov\security\Security',

        'certificateFile' => '',    // alias or path to default certificate file
        // or
        'publicKeyFile' => '',      // alias or path to default public key file

        'privateKeyFile' => '',     // alias or path to default private key file
        'passphrase' => '',         // passphrase to default private key (if exists)
    ],
    ...
],

Basic usages

Encryption

Asymmetric encryption

Will return base64 encoded encrypted data., (*9)

With default public key
Yii::$app->security->encryptByPublicKey(
    $data           // string data for ecnryption
);
With custom public key
Yii::$app->security->encryptByPublicKey(
    $data,          // string data for ecnryption
    $publicKey      // alias or path to custom public key or PEM formatted public key
);

Hybrid encryption

Will return array from encryption key and encrypted data \['key' => '...', 'data' => '...']).['key' => '...', 'data' => '...'])., (*10)

With default public key
Yii::$app->security->encryptHybrid(
    $data           // string data for ecnryption
);
With custom public key
Yii::$app->security->encryptHybrid(
    $data,          // string data for ecnryption
    $publicKey      // alias or path to custom public key or PEM formatted public key
);

Decryption

Asymmetric decryption

Will return decrypted data., (*11)

With default private key
Yii::$app->security->decryptByPrivateKey(
    $data           // string data for decryption
);
With custom private key
Yii::$app->security->decryptByPrivateKey(
    $data,          // string data for decryption
    $privateKey,    // alias or path to custom private key or PEM formatted private key
    $passphrase     // passphrase for private key (if exists)
);

Hybrid encryption

Will return decrypted data., (*12)

With default private key
Yii::$app->security->decryptHybrid(
    $data,          // string data for decryption or array from 
                    // encryption key and ecnrypted data (['key' => '...', 'data' => '...'])
    $key            // encryption key if $data as string
);
With custom private key
Yii::$app->security->decryptHybrid(
    $data,          //string data for decryption or array from 
                    // encryption key and ecnrypted data (['key' => '...', 'data' => '...'])
    $key,           // encryption key if $data as string
    $privateKey,    // alias or path to custom private key or PEM formatted private key
    $passphrase     // passphrase for private key (if exists)
);

The Versions

11/01 2017

dev-master

9999999-dev

Yii2 extension for openssl encryption by public/private keys

  Sources   Download

MIT

The Requires

 

The Development Requires

by Misha Serenkov

yii2 security encrypt decrypt openssl private public keys

11/01 2017

v1.0

1.0.0.0

Yii2 extension for openssl encryption by public/private keys

  Sources   Download

MIT

The Requires

 

The Development Requires

by Misha Serenkov

yii2 security encrypt decrypt openssl private public keys