承接 vereschak/url-encryptor-bundle 相关项目开发

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

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

vereschak/url-encryptor-bundle

Composer 安装命令:

composer require vereschak/url-encryptor-bundle

包简介

The NzoUrlEncryptorBundle is a Symfony Bundle used to Encrypt and Decrypt data and variables in the Web application or passed through URL

README 文档

README

Build Status Total Downloads Latest Stable Version

The NzoUrlEncryptorBundle is a Symfony Bundle used to Encrypt and Decrypt data and variables in the Web application or passed through the URL to provide more security to the project. Also it prevent users from reading and modifying sensitive data sent through the URL.

Features include:

  • Compatible Symfony version 2, 3 & 4
  • Url Data & parameters Encryption
  • Url Data & parameters Decryption
  • Data Encryption & Decryption
  • Access from Twig by ease
  • Flexible configuration
  • Compatible php version 5 & 7
  • Uses OpenSSL extension

Installation

Through Composer:

Install the bundle:

$ composer require vereschak/url-encryptor-bundle

Register the bundle in app/AppKernel.php (Symfony V2 or V3):

// app/AppKernel.php

public function registerBundles()
{
    return array(
        // ...
        new Nzo\UrlEncryptorBundle\NzoUrlEncryptorBundle(),
    );
}

Configure your application's config.yml:

Configure your secret encryption key:

# app/config/config.yml (Symfony V2 or V3)
# config/packages/nzo_url_encryptor.yaml (Symfony V4)

nzo_url_encryptor:
    secret_key: YourSecretEncryptionKey    # optional, max length of 100 characters.
    secret_iv:  YourIvEncryptionKey        # optional, max length of 100 characters.
    cipher_algorithm:                      # optional, default: 'aes-256-ctr'

Usage

In the twig template:

Use the twig extensions filters or functions to encrypt or decrypt your data:

// Filters:

# Encryption:

    <a href="{{path('my-route', {'id': MyId | urlencrypt } )}}"> My link </a>

    {{MyVar | urlencrypt }}

# Decryption:

    <a href="{{path('my-route', {'id': MyId | urldecrypt } )}}"> My link </a>

    {{MyVar | urldecrypt }}


// Functions:

# Encryption:

    <a href="{{path('my-path-in-the-routing', {'id': nzoEncrypt('MyID') } )}}"> My link </a>

    {{ nzoEncrypt(MyVar) }}

# Decryption:

    <a href="{{path('my-path-in-the-routing', {'id': nzoDecrypt('MyID') } )}}"> My link </a>

    {{ nzoDecrypt(MyVar) }}

In the routing.yml:

# routing.yml

my-path-in-the-routing:
    path: /my-url/{id}
    defaults: {_controller: MyBundle:MyController:MyFunction}

In the controller with annotation service:

Use the annotation service to decrypt / encrypt automatically any parameter you want, by using the ParamDecryptor / ParamEncryptor annotation service and specifying in it all the parameters to be decrypted/encrypted.

use Nzo\UrlEncryptorBundle\Annotations\ParamDecryptor;
//...

    /**
     * @ParamDecryptor(params={"id", "bar"})
     */
     public function indexAction($id, $bar)
    {
        // no need to use the decryption service here as the parameters are already decrypted by the annotation service.
        //...
    }
    
    
    
    use Nzo\UrlEncryptorBundle\Annotations\ParamEncryptor;
    //...
    
        /**
         * @ParamEncryptor(params={"id", "bar"})
         */
         public function indexAction($id, $bar)
        {
            // no need to use the encryption service here as the parameters are already encrypted by the annotation service.
            //...
        }

In the controller without annotation service:

Use the decrypt function of the service to decrypt your data:

     public function indexAction($id) 
    {
        $MyId = $this->get('nzo_url_encryptor')->decrypt($id);

        //...
    }

You can also use the encrypt function of the service to encrypt your data:

     public function indexAction() 
    {   
        //...
        
        $Encrypted = $this->get('nzo_url_encryptor')->encrypt($data);
        //...
    }

License

This bundle is under the MIT license. See the complete license in the bundle:

See Resources/doc/LICENSE

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固