Download the PHP package hiimlamxung/eup-encrypt-api without Composer

On this page you can find all versions of the php package hiimlamxung/eup-encrypt-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package eup-encrypt-api

eup-encrypt-api

1. Mô tả:

Thêm provider vào trong config:

$providers = [
        ...
      Hiimlamxung\EupEncryptApi\EupEncryptApiServiceProvider::class
],

Publish file config: run php artisan vendor:publish --provider="Hiimlamxung\EupEncryptApi\EupEncryptApiServiceProvider"

4. Sử dụng:

4.1. Sử dụng mã hoá AES để encrypt response API

Thiết lập đầu tiên:

Trước khi sử dụng cần thiết lập theo các bước sau:

Sử dụng:

Encypt data cần mã hoã (dạng chuỗi) trả về response API.

Sử dụng EupCrypt Facade: use \Hiimlamxung\EupEncryptApi\App\Facades\EupCrypt;

$users = User::get();
$jsonData = json_encode($users); //Chuyển data sang dạng chuỗi json
$encryptedData = EupCrypt::encrypt($jsonData); //Mã hoá data

return response()->json[
    'code' => 200,
    'data' => $encryptedData
]

4.2 Sử dụng mã hoá RSA để decrypt request từ phía client

Thiết lập đầu tiên:

Lưu privateKey và publicKey vào 2 file khác nhau. Nếu bạn chưa có sẵn key, chạy đoạn code sau để tự tạo và lấy nội dung key:

\Hiimlamxung\EupEncryptApi\App\RSA::createKey(); // tạo mới và trả về nội dung của publicKey, privateKey

Bổ sung đường dẫn key file vào trong config:

'decrypt_req' => [
    /**
     * ----------------------------------------------------------------
     * Đường dẫn file key tính từ thư mục gốc
     * ----------------------------------------------------------------
     */
    'path_key' => [
        'public_key' => '/env/publicKey.txt',
        'private_key' => '/env/privateKey.txt',
    ]
]
Sử dụng:

Tạo 1 middleware mới (Tên theo ý muốn) để áp dụng cho các route cần decrypt. Middleware này cần kế thừa lại middleware của package \Hiimlamxung\EupEncryptApi\App\Http\Middleware\CanDecryptRSA

run php artisan make:middleware CanDecryptRSA

Middleware mới tạo sẽ như sau:

<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
use Hiimlamxung\EupEncryptApi\App\Http\Middleware\CanDecryptRSA as EupCanDecryptRSA;

class CanDecryptRSA extends EupCanDecryptRSA
{

    /**
    * Xoá đi method handle, hoặc comment lại, không dùng nữa (Bắt buộc).
    */ 
    // public function handle(Request $request, Closure $next): Response

    // }

    public function failedResponse(Request $request, Closure $next)
    {
        // Logic xử lý của bạn khi không thể decrypt được data ở đây.
        return response()->json[
            'code' => 422,
            'message' => 'Could not decrypt the data'
        ]
    }
}

Middleware này sẽ check và giải mã request có param name là 'encrypted_data' từ phía client gửi lên. Nếu muốn sử dụng param name khác có thể định nghĩa lại trong config

    'decrypt_req' => [
    /**
     * ----------------------------------------------------------------
     * Tên trường dữ liệu đã được mã hoá do client gửi lên
     * ----------------------------------------------------------------
     */
    'encrypted_data_name' => 'encrypted_data',

Done! Việc còn lại là đăng ký middleware vào Kernel.php và áp dụng cho route muốn dùng

    protected $middlewareAliases = [
    ...
    'can.decrypt.rsa' => \App\Http\Middleware\CanDecryptRSA::class
];

Sử dụng trong route:

Route::post('/update', 'UserController@update')->middleware('can.decrypt.rsa');

/**
* Có thể tự định nghĩa param name riêng biệt muốn check,
* thay vì lấy theo trong config là 'encrypted_data'.
* Ở đây ta lấy theo param name là encryt_param
*/
Route::post('/store', 'UserController@store')->middleware('can.decrypt.rsa:encryt_param');

DONE. Nếu thấy bug thì contact ngay [email protected] =))

Chúc bạn may mắn và làm thành công =))


All versions of eup-encrypt-api with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hiimlamxung/eup-encrypt-api contains the following files

Loading the files please wait ....