Download the PHP package yexiaofeng/hashid without Composer

On this page you can find all versions of the php package yexiaofeng/hashid. 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 hashid

介绍

一个对Laravel应用模型ID进行对称加密的辅助函数。

依赖于hashids/hashids

基于jiaxincui/hashid进行了修改,支持Laravel 9.

只适用于正整数加密。

安装

配置

  1. 复制config/hashid.php文件到Laravel项目的config文件夹。
  2. 在.env文件添加配置项HASH_ID_ALPHABET=your-key
    • 为了Hash成更安全的字符串,请手动重新生成HASH_ID_ALPHABET,为0-9a-zA-Z共62个字符随机排序,字符不可重复,长度为16-62,可使用以下方法生成

简单使用

包含两个辅助方法id_encode()id_decode()。 在Laravel项目的任何地方均可使用这两个函数对ID进行加密或解密。

例子

hashids/hashids不同的是hashids提供多个数字或包含多个数字的数组加密成一个字符串, 解密时以数组形式返回,这在实际应用中并不常见,反而给使用带来一定麻烦, 而此包对此进行了一些处理,不提供多个数字或多个数字数组的加密,解密时直接返回解密后的数字。

Laravel深度应用

加密

有2种方法实现自动加密

解密

通过Hashid提供的middleware对路由参数解码,在控制器中无需做任何操作即可解码加密后的路由参数。 首先在App\Http\Kernel.php中注册中间件,在Kernel类的$routeMiddleware属性添加中间件条目。例如:

现在你可以在路由中分配中间件了。例如:

中间件参数

默认情况下,Hashid中间件会解密当前路由的所有路由参数,如果你想指定被解密的路由参数可在中间件传入参数,例如:

以上例子中间件只解密给出的参数,如以上例子会解密路由参数userpost,不会解密commnent

现在你的应用已经具备完整的加密和解密模型ID的功能。


All versions of hashid with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
hashids/hashids Version ^4.0
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 yexiaofeng/hashid contains the following files

Loading the files please wait ....