定制 msolutions/file-access-encryptor 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

msolutions/file-access-encryptor

Composer 安装命令:

composer require msolutions/file-access-encryptor

包简介

Encrypt your real file path with expiry

README 文档

README

Version 1.0

This library will support you to hide/prevent accessing files through the real location

Features

  • Hide your files real location
  • URL expiration
  • Regenerate secure unique urls

Installation

composer require msolutions/file-access-encryptor

Implementing

use MSL\FileAccessEncryptor;

/*initialize the class inside your 
 *constructor or any other function before using
 **/
public function __constructor()
{
    new FileAccessEncryptor();
}

//Generate encrypted token for your files
$realFilePath = '/path/pdf/mypdf.pdf';
$urlExpirationTime = 60; //60 seconds (apply the time in seconds)
$encryptedToken = FileAccessEncryptor::encryptRealPath($realFilePath, $urlExpirationTime);

Decrypting Token

use MSL\FileAccessEncryptor;

/*initialize the class inside your 
 *constructor or any other function before using
 **/
public function __constructor()
{
    new FileAccessEncryptor();
}

//decrypt the token and get the real file path
FileAccessEncryptor::name("Give-Some-File-Name"); //optional

//encryption value mutation to get the real url (optional)
FileUrlEncryptor::mutateRealPath(function($value){
            return $value+1;
});

//Preview the file (if need to preview the secure object)
$encryptedToken = 'ENC-TOKEN';
FileAccessEncryptor::type("pdf"); //[pdf, jpg, jpeg] parse here your file type for preview purpose
FileUrlEncryptor::preview($encryptedToken);

//decrypt and get the real file path and expiry status
$encryptedToken = 'ENC-TOKEN';
$result = FileAccessEncryptor::decryptRealPath($encryptedToken);
/*
return ["status" => "valid", "path" => "/path/for-real-file.pdf"];

OR

return ["status" => "expired", "path" => null];
*/

This open source package is developed for general use, any of developers can use this for free.

  • Please share your comments and ideas to improve the package.

FileAccessEncryptor

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固