bonecms/laravel-query-signer

Laravel 的查询签名器

1.1 2020-01-03 06:12 UTC

This package is auto-updated.

Last update: 2024-08-29 04:54:21 UTC


README

支持版本:5.6 及以上

安装查询签名器

注意:如果您还没有Composer,可以通过访问https://getcomposer.org.cn上的说明进行安装

安装包

composer require bonecms/laravel-query-signer

使用查询签名器

生成签名

<?php 

use Bone\Signer\Facades\Signer;

$array = [
    5,
    'string' => 'example',
    'array'  => [
        'example'
    ]
];

$sign = Signer::sign($array);

检查签名

<?php 

use Bone\Signer\Facades\Signer;

$array = [
    5,
    'string' => 'example',
    'array'  => [
        'example'
    ]
];
$sign = '$2y$10$wDtYOVXK5J9XCD6Vx.taNevviw5aVsVp1rBrkpaB.9xLwHHORgqya';

$verified = Signer::verify($array, $sign);
if ($verified) {
    // do something
}

配置

php artisan vendor:publish --tag=bone-data-signer-config
<?php

return [
    /*
    |--------------------------------------------------------------------------
    | Passphrase
    |--------------------------------------------------------------------------
    | The passphrase that will be added to the row for hashing.
    */
    'passphrase' => env('SIGNER_PASSPHRASE', 'Your super secret passphrase'),
    
    /*
    |--------------------------------------------------------------------------
    | Cost
    |--------------------------------------------------------------------------
    | Cost which denotes the algorithmic cost that should be used.
    */
    'cost' => env('SIGNER_COST', 10),
];