hashids / hashids.github.io

This is the old Hashids website. It is no longer maintained and has migrated over to Sqids.
https://sqids.org
206 stars 34 forks source link

lower case IDs (case-insensitive) #25

Closed siddo420 closed 8 years ago

siddo420 commented 8 years ago

I am thinking of using hash IDs in one of my projects.

However, the IDs must be case insensitive (all lower case). So, I was thinking of adding digit(s) (0-F) at the end after a period(.) or hyphen(-).

The number of digits will depend on length of ID and bits in digit will represent positions of capital letters in ID.

For example, if the ID generated is: 0R9ty3En We need 8 bits to represent 8 chars. And, positions (assuming 'n' is at 0) 1 and 6 are capital. Hence, we need: 01000010

which in hex translates to: 42.

So, complete hex id would now be: 0r9ty3en-42 (all lower case that can be translated back to original easily).

Is there a better way to do this?

jd327 commented 8 years ago

Yes. Pass all lowercase alphabet to the constructor.