-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
code style
- Loading branch information
Showing
19 changed files
with
186 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
on: | ||
push: | ||
# Sequence of patterns matched against refs/tags | ||
tags: | ||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
|
||
name: Release | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
<?php | ||
|
||
$header = <<<'EOF' | ||
This file is part of Hyperf. | ||
This file is part of hyperf-ext/encryption. | ||
@link https://www.hyperf.io | ||
@document https://hyperf.wiki | ||
@contact [email protected] | ||
@license https://github.com/hyperf/hyperf/blob/master/LICENSE | ||
@link https://github.com/hyperf-ext/encryption | ||
@contact [email protected] | ||
@license https://github.com/hyperf-ext/encryption/blob/master/LICENSE | ||
EOF; | ||
|
||
return PhpCsFixer\Config::create() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of hyperf-ext/encryption. | ||
* | ||
* @link https://github.com/hyperf-ext/encryption | ||
* @contact [email protected] | ||
* @license https://github.com/hyperf-ext/encryption/blob/master/LICENSE | ||
*/ | ||
return [ | ||
|
||
'default' => 'aes', | ||
|
||
'driver' => [ | ||
|
||
'aes' => [ | ||
'class' => \HyperfExt\Encryption\Driver\AesDriver::class, | ||
'options' => [ | ||
'key' => env('AES_KEY', ''), | ||
'cipher' => env('AES_CIPHER', 'AES-128-CBC'), | ||
], | ||
], | ||
|
||
], | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of hyperf-ext/encryption. | ||
* | ||
* @link https://github.com/hyperf-ext/encryption | ||
* @contact [email protected] | ||
* @license https://github.com/hyperf-ext/encryption/blob/master/LICENSE | ||
*/ | ||
namespace HyperfExt\Encryption\Command; | ||
|
||
use Hyperf\Command\Command as HyperfCommand; | ||
|
@@ -33,23 +39,21 @@ public function configure() | |
*/ | ||
public function handle() | ||
{ | ||
$driverName = $this->choice('Select driver', array_keys($this->config->get('ext-encryption.driver'))); | ||
$driverName = $this->choice('Select driver', array_keys($this->config->get('encryption.driver'))); | ||
|
||
$key = $this->generateRandomKey($driverName); | ||
|
||
$this->line('<comment>'.$key.'</comment>'); | ||
$this->line('<comment>' . $key . '</comment>'); | ||
} | ||
|
||
/** | ||
* Generate a random key for the application. | ||
* | ||
* @param string $driverName | ||
* | ||
* @return string | ||
*/ | ||
protected function generateRandomKey(string $driverName) | ||
{ | ||
$config = $this->config->get("ext-encryption.driver.{$driverName}"); | ||
$config = $this->config->get("encryption.driver.{$driverName}"); | ||
return call([$config['class'], 'generateKey'], [['options' => $config['options']]]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of hyperf-ext/encryption. | ||
* | ||
* @link https://github.com/hyperf-ext/encryption | ||
* @contact [email protected] | ||
* @license https://github.com/hyperf-ext/encryption/blob/master/LICENSE | ||
*/ | ||
namespace HyperfExt\Encryption; | ||
|
||
use HyperfExt\Encryption\Command\GenKeyCommand; | ||
|
@@ -22,8 +28,8 @@ public function __invoke(): array | |
[ | ||
'id' => 'config', | ||
'description' => 'The config for HyperfExt\\Encryption.', | ||
'source' => __DIR__ . '/../publish/ext-encryption.php', | ||
'destination' => BASE_PATH . '/config/autoload/ext-encryption.php', | ||
'source' => __DIR__ . '/../publish/encryption.php', | ||
'destination' => BASE_PATH . '/config/autoload/encryption.php', | ||
], | ||
], | ||
]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of hyperf-ext/encryption. | ||
* | ||
* @link https://github.com/hyperf-ext/encryption | ||
* @contact [email protected] | ||
* @license https://github.com/hyperf-ext/encryption/blob/master/LICENSE | ||
*/ | ||
namespace HyperfExt\Encryption\Contract; | ||
|
||
interface AsymmetricDriverInterface extends DriverInterface | ||
{ | ||
public function getPublicKey(): string; | ||
|
||
public function getPrivateKey(): string; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of hyperf-ext/encryption. | ||
* | ||
* @link https://github.com/hyperf-ext/encryption | ||
* @contact [email protected] | ||
* @license https://github.com/hyperf-ext/encryption/blob/master/LICENSE | ||
*/ | ||
namespace HyperfExt\Encryption\Contract; | ||
|
||
interface DriverInterface | ||
|
@@ -10,9 +16,6 @@ interface DriverInterface | |
* Encrypt the given value. | ||
* | ||
* @param mixed $value | ||
* @param bool $serialize | ||
* | ||
* @return string | ||
* | ||
* @throws \HyperfExt\Encryption\Exception\EncryptException | ||
*/ | ||
|
@@ -21,12 +24,8 @@ public function encrypt($value, bool $serialize = true): string; | |
/** | ||
* Decrypt the given value. | ||
* | ||
* @param string $payload | ||
* @param bool $unserialize | ||
* | ||
* @return mixed | ||
* | ||
* @throws \HyperfExt\Encryption\Exception\DecryptException | ||
* @return mixed | ||
*/ | ||
public function decrypt(string $payload, bool $unserialize = true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of hyperf-ext/encryption. | ||
* | ||
* @link https://github.com/hyperf-ext/encryption | ||
* @contact [email protected] | ||
* @license https://github.com/hyperf-ext/encryption/blob/master/LICENSE | ||
*/ | ||
namespace HyperfExt\Encryption\Contract; | ||
|
||
interface EncryptionInterface extends DriverInterface | ||
{ | ||
/** | ||
* Get a driver instance. | ||
* | ||
* @param string|null $name | ||
* | ||
* @return \HyperfExt\Encryption\Contract\DriverInterface | ||
*/ | ||
public function getDriver(?string $name = null): DriverInterface; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of hyperf-ext/encryption. | ||
* | ||
* @link https://github.com/hyperf-ext/encryption | ||
* @contact [email protected] | ||
* @license https://github.com/hyperf-ext/encryption/blob/master/LICENSE | ||
*/ | ||
namespace HyperfExt\Encryption\Contract; | ||
|
||
interface SymmetricDriverInterface extends DriverInterface | ||
{ | ||
public function getKey(): string; | ||
|
||
public static function generateKey(array $options = []): string; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of hyperf-ext/encryption. | ||
* | ||
* @link https://github.com/hyperf-ext/encryption | ||
* @contact [email protected] | ||
* @license https://github.com/hyperf-ext/encryption/blob/master/LICENSE | ||
*/ | ||
namespace HyperfExt\Encryption; | ||
|
||
use Hyperf\Utils\ApplicationContext; | ||
use HyperfExt\Encryption\Contract\DriverInterface; | ||
use HyperfExt\Encryption\Contract\EncryptionInterface; | ||
use Hyperf\Utils\ApplicationContext; | ||
|
||
abstract class Crypt | ||
{ | ||
|
Oops, something went wrong.