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.27k stars 417 forks source link

Negative numbers #127

Closed joshbruce closed 5 years ago

joshbruce commented 5 years ago

Hey, long time user, first time poster.

Curious if there are any plans to support negative ids?

It's an odd use case and not something I can't get around, but would be nice to get hashes from either side of zero to divide a larger set of things.

Thanks. Appreciate the library.

jd327 commented 5 years ago

@joshbruce Sorry for the late reply. There's no plans atm to support negative numbers. However, you could abstract by prepending your own designated number, like [1, 2, -3] could become [1, 2, 0, 3]. Of course there are other downsides to that.

joshbruce commented 5 years ago

Thanks @ivanakimov, appreciate that alternative. I figured out an alternative to ultimately hit the same goal.