hbnext/encrypt-decrypt-bundle

安装: 5

依赖: 0

建议者: 0

安全: 0

星星: 0

关注者: 1

分支: 0

开放问题: 0

类型:symfony-bundle

1.0.0 2021-07-19 22:49 UTC

This package is not auto-updated.

Last update: 2024-09-25 11:30:03 UTC


README

加密和解密字符串。安装步骤

步骤 1:下载Bundle

打开命令行,进入项目目录,然后执行以下命令以下载此Bundle的最新稳定版本

$ composer require hbnext/encrypt-decrypt-bundle

此命令需要您全局安装Composer,请参阅Composer文档中的安装章节了解详情。

步骤 2:启用Bundle

在Symfony中,该包将自动激活。但如果出现问题,您可以手动安装。

然后,通过将以下内容添加到项目config/bundles.php文件中已注册的Bundle列表中来启用Bundle

<?php
// config/bundles.php

return [
    //...
     hbNext\EncryptDecryptBundle\EncryptDecryptBundle::class => ['all' => true]
];

步骤 3:启用Bundle

在config/packages/encrypt_decrypt.yaml中配置密钥

encrypt_decrypt:
  key: haikel

步骤 4:功能说明

此包允许您加密和解密字符串。一旦安装,您就可以执行以下操作:

PHP
    
    use hbNext\EncryptDecryptBundle\services\EncryptionInterface;
    
    private EncryptionInterface $encryption;

    public function __construct(EncryptionInterface $encryption )
    {

        $this->encryption =$encryption;
    }
     $text="mytext";
     $this->encryption->encrypt($text);
     $this->encryption->decrypt(  $this->encryption->encrypt($text));
TWIG
   {{ encrypt('haikel') }}
   {{ decrypt('aGFpa2VsMzQ3YWFlOGMwODJjNzc3ZTg0MzE1MGY1ZTA5Mjc4MzE=') }}