cdoco / Hashids.phpc
Licence: other
🐘 A php extension for Hashids: generate short unique ids from integers.
Stars: ✭ 43
Programming Languages
c
50402 projects - #5 most used programming language
Labels
Projects that are alternatives of or similar to Hashids.phpc
laravel-hashid
HashId Implementation on Laravel Eloquent ORM
Stars: ✭ 23 (-46.51%)
Mutual labels: hashids
Hashids.net
A small .NET package to generate YouTube-like hashes from one or many numbers. Use hashids when you do not want to expose your database ids to the user.
Stars: ✭ 470 (+993.02%)
Mutual labels: hashids
hashids-bundle
Integrates hashids/hashids in a Symfony project
Stars: ✭ 43 (+0%)
Mutual labels: hashids
id-mask
IDMask is a Java library for masking internal ids (e.g. from your DB) when they need to be published to hide their actual value and to prevent forging. It has support optional randomisation has a wide support for various Java types including long, UUID and BigInteger. This library bases its security on strong cryptographic primitives.
Stars: ✭ 39 (-9.3%)
Mutual labels: hashids
bashids
Pure Bash implementation of the hashid algorithm from http://hashids.org/
Stars: ✭ 38 (-11.63%)
Mutual labels: hashids
Hashid Rails
Use Hashids (http://hashids.org/ruby/) in your Rails app ActiveRecord models.
Stars: ✭ 225 (+423.26%)
Mutual labels: hashids
Hashids.rb
A small Ruby gem to generate YouTube-like hashes from one or many numbers. Use hashids when you do not want to expose your database ids to the user.
Stars: ✭ 842 (+1858.14%)
Mutual labels: hashids
Laravel Hashid
Obfuscate your data by generating reversible, non-sequential, URL-safe identifiers.
Stars: ✭ 354 (+723.26%)
Mutual labels: hashids
objection-hashid
Objection plugin to automatically obfuscate model ids using hashids!
Stars: ✭ 13 (-69.77%)
Mutual labels: hashids
Django Hashid Field
Django Model Field that uses Hashids to obscure the value
Stars: ✭ 256 (+495.35%)
Mutual labels: hashids
Hashids
A small PHP library to generate YouTube-like ids from numbers. Use it when you don't want to expose your database ids to the user.
Stars: ✭ 4,596 (+10588.37%)
Mutual labels: hashids
Laravel Hashids
Integrate Hashids with Laravel. Automatic model binding and id resolving included!
Stars: ✭ 8 (-81.4%)
Mutual labels: hashids
Go Hashids
Go (golang) implementation of http://www.hashids.org
Stars: ✭ 830 (+1830.23%)
Mutual labels: hashids
Hashids.js
A small JavaScript library to generate YouTube-like ids from numbers.
Stars: ✭ 3,525 (+8097.67%)
Mutual labels: hashids
A php extension for Hashids
Requirement
- PHP 7 +
Install
$ git clone https://github.com/cdoco/hashids.phpc.git
$ cd hashids.phpc
$ phpize && ./configure && make && make install
you can set some options in php.ini, or set in the constructor. i suggest you in php.ini setting, so you will get better performance.
[hashids]
extension=hashids.so
//default is empty
hashids.salt=cdoco
//default: 0
hashids.min_hash_length=20
//default: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890
//you can use to set it according to your own, for example, is set to all lowercase
hashids.alphabet=abcdefghijklmnopqrstuvwxyz
Quick Example
$hashids = new Hashids();
$hash = $hashids->encode(1, 2, 3, 4, 5); // ADf9h9i0sQ
$numbers = $hashids->decode($hash); // [1, 2, 3, 4, 5]
//or would you prefer to use a static method call
$hash = Hashids::encode(1, 2, 3, 4, 5); // ADf9h9i0sQ
$numbers = Hashids::decode($hash); // [1, 2, 3, 4, 5]
Performance
php extension and only php code performance contrast.
Other
$hashids = new Hashids();
$hash = $hashids->encode(1, 2, 3, 4, 5); // ADf9h9i0sQ
$hash = $hashids->encode([1, 2, 3, 4, 5]); // ADf9h9i0sQ
construct parameter.
new Hashids(string $salt, int $min_hash_length, string $alphabet);
//example
new Hashids("this is salt.", 20, 'abcdefghijklmnopqrstuvwxyz');
hex.
$hashids = new Hashids();
$hash = $hashids->encodeHex('FFFFDD'); // rYKPAK
$hex = $hashids->decodeHex($hash); // FFFFDD
Curses! #$%@
This code was written with the intent of placing created ids in visible places, like the URL. Therefore, the algorithm tries to avoid generating most common English curse words by generating ids that never have the following letters next to each other:
c, f, h, i, s, t, u
License
PHP License. See the LICENSE file.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].