vinkla / 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.
https://hashids.org/php
MIT License
5.28k stars 418 forks source link

Using for Short URLs? #138

Closed ash-jc-allen closed 4 years ago

ash-jc-allen commented 4 years ago

Hi, I've recently written a Laravel package (https://github.com/ash-jc-allen/short-url) that can be used for creating short URLs.

I give the developer who's using it the option to set the length of their URL key (the unique, short part of the URL). In testing, someone realised that if a user runs out of unique combinations at the specified length that it will break.

I'm thinking of changing the 'URL key length' to a 'minimim URL key length' instead. So, as an example, if all possible 3 character long strings are taken, a 4 character long one will be made instead.

I need to store the unique keys in the database. So, would this package be suitable for generating the unique keys that I need? Would it be able to automatically increase its length if I ran out of possible combinations at a certain length?

Sorry if this doesn't make much sense. Thanks in advance!

vinkla commented 4 years ago

Yes, I think the Hashids package could be a good fit in your scenario.