limingxinleo/i-encryption

Illuminate Encryption for Hyperf

v1.0.0 2021-02-05 08:53 UTC

This package is auto-updated.

Last update: 2021-05-05 09:28:26 UTC


README

illuminate/encryption

安装

composer require limingxinleo/i-encryption

配置

<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
return [
    'default' => [
        'key' => '',
        'cipher' => '',
    ],
];

使用

use Hyperf\Utils\ApplicationContext;
use Illuminate\Encryption\Contracts\Encrypter;

$encrypter = ApplicationContext::getContainer()->get(Encrypter::class);

$encrypted = $encrypter->encrypt('foo');
$decrypted = $encrypter->decrypt($encrypted);