New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is "minAlphabetLength = 16" required? #21
Comments
Looks like you're using a bit of an older version, where min length is 2. But for newer versions, check out these comments as to why 16 is minimum: |
Thank you very much! So I can just use alphabet coffee> hashids = new (require 'hashids') "aaa", 9, "0123456789cfhistuCFHISTU"
{ version: '1.0.2',
minAlphabetLength: 16,
sepDiv: 3.5,
guardDiv: 12,
errorAlphabetLength: 'error: alphabet must contain at least X unique characters',
errorAlphabetSpace: 'error: alphabet cannot contain spaces',
alphabet: '602137945',
seps: 'IcHFihUufCStsT',
minHashLength: 9,
salt: 'aaa',
guards: '8' }
coffee> hashids.encode 1
'120805874'
coffee> hashids.encode 100000
'869749698'
coffee> hashids.decode '120805874'
[ 1 ] |
Yes. Also for your use-case, check out |
@ivanakimov Great! Thanks for the info. |
I'm using "0123456789cfhistuCFHISTU" too, and I only get numbers which is what I'm looking for, but I don't understand why 😂️ It is said that "the algorithm tries to avoid generating most common English curse words by never placing the following letters (and their uppercase equivalents) next to each other". So, how is it that those letters are not even found one time in the generated hashids? It could be put between 2 numbers, no? |
@godbout IIRC those characters are used for separators when you encoding an array |
@liukun yeah I saw that in the doc, but from what I understood from the doc and the source, those letters could still show up in the generated hashid. But like you, I just receive numbers, which I find very strange (although this is what I want, but I can't confirm that it would then work all the time?). I don't use Optimus neither because I want to control the length of the numbers generated. |
@godbout Array separator
|
🤦🏻♂️😂 Got it sorry. Holiday mood 😂 |
I tried only use numbers as alphabet, and seems worked:
Are there some implicit requirements in algorithm?
The text was updated successfully, but these errors were encountered: