litepie / hashids
The Litepie Hashids package.
Requires
- php: ^8.1|^8.2
- hashids/hashids: ~4.0
- dev-master
- 10.x-dev
- v10.2.2
- v7.0.0
- v5.1.6
- v5.1.4
- v5.1.3
- v5.1.2
- v5.1.1
- v5.0.3
- v5.0.2
- v5.0.1
- v5.0.0
- 4.2.x-dev
- 4.2.5
- 4.1.x-dev
- 4.1.4
- 4.0.x-dev
- 4.0.21
- 4.0.20
- v3.1.13
- v3.1.12
- 3.0.x-dev
- v3.0.9
- 2.2.x-dev
- 2.1.x-dev
- 2.0.x-dev
- 1.4.x-dev
- 1.3.x-dev
- 1.2.x-dev
- 1.1.x-dev
- 1.0.x-dev
- dev-develop
- dev-activities_update
- dev-hotfix/master_package
- dev-hotfix/user_package
This package is auto-updated.
Last update: 2024-11-08 16:13:40 UTC
README
This package uses the classes created by hashids.org
Generate hashes from numbers, like YouTube or Bitly. Use hashids when you do not want to expose your database ids to the user.
Installation
To get the latest version of Hashids simply require it in your composer.json
file.
"litepie/hashids": "2.0.*@dev"
You'll then need to run composer install
to download it and have the autoloader updated.
Once Hashids is installed you need to register the service provider with the application. Open up config/app.php
and find the providers
key.
'Litepie\Library\Hashids\HashidsServiceProvider'
There is no need to add the Facade, the package will add it for you.
Publish the configurations
Run this on the command line from the root of your project:
$ php artisan vendor:publish
A configuration file will be publish to config/hashids.php
.
Laravel 4 Installation
Add verison 1.0 of Hashids in your composer.json
file.
"litepie/hashids": "1.0.*"
And following the directions in the README on version 1.0.
Usage
Once you've followed all the steps and completed the installation you can use Hashids.
Encodeing
You can simply encode a single id:
Hashids::encode(1); // Returns Ri7Bi
or multiple..
Hashids::encode(1, 21, 12, 12, 666); // Returns MMtaUpSGhdA
Decodeing
Hashids::decode(Ri7Bi); // Returns array (size=1) 0 => int 1
or multiple..
Hashids::decode(MMtaUpSGhdA); // Returns array (size=5) 0 => int 1 1 => int 21 2 => int 12 3 => int 12 4 => int 666
Changelog
2.0.0
- Upgraded to Laravel 5
- Upgraded to Hashids 1.0.5
1.0.0
-
Several public functions are renamed to be more appropriate:
- Function
encrypt()
changed toencode()
- Function
decrypt()
changed todecode()
- Function
encryptHex()
changed toencodeHex()
- Function
decryptHex()
changed todecodeHex()
Hashids was designed to encode integers, primary ids at most. Hashids is the wrong algorithm to encrypt sensitive data. So to encourage more appropriate use,
encrypt/decrypt
is being "downgraded" toencode/decode
. - Function
-
Version tag added:
1.0
-
README.md
updated
All credit for Hashids goes to Ivan Akimov (@ivanakimov), thanks to for making it!