speps / go-hashids

Go (golang) implementation of http://www.hashids.org
MIT License
1.32k stars 109 forks source link

Minimum Alphabet Length #9

Closed pjebs closed 8 years ago

pjebs commented 9 years ago

What is the consequence of changing the minimum alphabet length to 10.

I want my alphabet to be "0123456789"?

I changed your code. I only want to encode numbers and it seems to work.

pjebs commented 9 years ago

Also does longer salts slow down the algorithm?

jd327 commented 9 years ago

16 chars alphabet requirement is there because we need at least 2 characters after separators, to make base alphabet work. So, since separators are 14 characters long, we need a min of 16 characters to still make it work with the worst alphabet scenario: "cfhistuCFHISTU01".

In other words, you should be fine using 0123456789 as custom alphabet in your modified lib, but I'd double check ID generation anyway.

Longer salts do not slow down the algorithm in any noticeable way.

pjebs commented 9 years ago

Can I make the seperators list blank i.e. '' because I don't actually are about bad words? I'll also only ever be encode ONE number so how can I get rid of the separators requirement?

jd327 commented 9 years ago

Honestly, I've never tested the lib without separators. But if you're encoding only one number, you'll never see them anyway.