承接 miserenkov/yii2-security 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

miserenkov/yii2-security

Composer 安装命令:

composer require miserenkov/yii2-security

包简介

Yii2 extension for openssl encryption by public/private keys

README 文档

README

Yii2 extension for encryption and decryption by openssl public/private keys

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

Support

GitHub issues.

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

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

to the require section of your composer.json file.

Configuration

To use security extension, you should configure it in the application configuration like the following

'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.

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' => '...']).

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.

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.

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)
);

统计信息

  • 总下载量: 61
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固