-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 02db11c
Showing
10 changed files
with
4,980 additions
and
0 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,3 @@ | ||
*.DS_Store | ||
.idea/ | ||
/vendor |
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,8 @@ | ||
language: php | ||
php: | ||
- 7.1 | ||
before_script: | ||
- composer install | ||
|
||
script: | ||
- vendor/bin/phpunit tests/CryptTest |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Jourdon <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,104 @@ | ||
# Crypt for laravel5.* or lumen | ||
|
||
--- | ||
[](https://travis-ci.org/ShaoZeMing/laravel-crypt) | ||
[](https://packagist.org/packages/shaozeming/laravel-crypt) | ||
[](https://packagist.org/packages/shaozeming/laravel-crypt) | ||
|
||
## Installing | ||
|
||
```shell | ||
$ composer require shaozeming/laravel-crypt -v | ||
``` | ||
### Laravel | ||
|
||
|
||
|
||
```php | ||
// config/app.php | ||
|
||
'providers' => [ | ||
//... | ||
ShaoZeMing\LaravelCrypt\CryptServiceProvider::class, //This is default in laravel 5.5 | ||
], | ||
``` | ||
|
||
And publish the config file: | ||
|
||
```shell | ||
$ php artisan vendor:publish --provider=ShaoZeMing\\LaravelCrypt\\CryptServiceProvider | ||
``` | ||
|
||
if you want to use facade mode, you can register a facade name what you want to use, for example `crypt`: | ||
|
||
```php | ||
// config/app.php | ||
|
||
'aliases' => [ | ||
'MingCrypt' => ShaoZeMing\LaravelCrypt\Facade\Crypt::class, //This is default in laravel 5.5 | ||
], | ||
``` | ||
|
||
### lumen | ||
|
||
- 在 bootstrap/app.php 中 82 行左右: | ||
``` | ||
$app->register( ShaoZeMing\LaravelCrypt\CryptServiceProvider::class); | ||
``` | ||
将 `vendor/ShaoZeMing/laravel-crypt/config/crypt.php` 拷贝到项目根目录`/config`目录下,并将文件名改成`crypt.php`。 | ||
|
||
### configuration | ||
|
||
```php | ||
// config/crypt.php | ||
|
||
|
||
/** | ||
* 本项目的app_secret | ||
*/ | ||
'app_secret' =>env('XTHK_APP_SECRET','12345678912345678912345678912312'), | ||
|
||
/** | ||
* 加密规则,支持AES-128-CBC,AES-256-CBC | ||
*/ | ||
'cipher' => env('XTHK_CIPHER','AES-256-CBC'), | ||
|
||
|
||
``` | ||
|
||
|
||
## Usage | ||
|
||
|
||
```php | ||
use Crypt; | ||
|
||
//第1种 | ||
$result = Crypt::crypt('你知道我对你不仅仅是喜欢'); | ||
print_r($result); | ||
|
||
|
||
|
||
|
||
``` | ||
|
||
|
||
Example: | ||
|
||
```php | ||
// 更换翻译服务商 | ||
$result = Crypt::setDriver('baidu')->crypt('你知道我对你不仅仅是喜欢'); | ||
print_r($result); | ||
|
||
// 更换翻译语言 可选语言请看配置文件中可定义的几种 | ||
$from="en"; | ||
$to="zh"; | ||
$result = Crypt::setFromAndTo($from,$to)->crypt('I love you.'); | ||
print_r($result); | ||
|
||
``` | ||
|
||
## License | ||
|
||
MIT | ||
|
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,43 @@ | ||
{ | ||
"name": "shaozeming/laravel-crypt", | ||
"description": "一个签名/验签,加密解密的laravel/lumen包", | ||
"type": "library", | ||
"require": { | ||
"laravel/framework": "~5.0", | ||
"shaozeming/crypt": "^1.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^6.3", | ||
"mockery/mockery": "^0.9.9" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "ShaoZeMing", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"ShaoZeMing\\LaravelCrypt\\": "./src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"ShaoZeMing\\LaravelCrypt\\Test\\": "./tests" | ||
} | ||
}, | ||
|
||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"ShaoZeMing\\LaravelCrypt\\CryptServiceProvider" | ||
], | ||
"aliases": { | ||
"MingCrypt": "ShaoZeMing\\LaravelCrypt\\Facade\\Crypt" | ||
} | ||
} | ||
}, | ||
"minimum-stability":"dev" | ||
|
||
} |
Oops, something went wrong.