speps/go-hashids

Minimum Alphabet Length

pjebs opened this issue · 4 comments

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.

Also does longer salts slow down the algorithm?

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.

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?

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