ai / nanoid

A tiny (124 bytes), secure, URL-friendly, unique string ID generator for JavaScript
https://zelark.github.io/nano-id-cc/
MIT License
24.6k stars 791 forks source link

[Technical question] 25 or 26 characters for base32 encoding? #391

Closed slimhk45 closed 2 years ago

slimhk45 commented 2 years ago

Hi, I need base32 uuid to encode hex uuid in filenames with fewer characters. But I'm confused: 128/5=25.6. Should I use 25 or 26 characters? Similarly, nanoid choose 21 characters over 22 (128/6=21.3). Why this choice?

Also a last question, what is the advantage of the base32hex (0-9, A-V) over the base32 (A-Z, 2-7) in this case (filename uuid)?

Thanks.

ai commented 2 years ago

26.

You need to choose bigger number to have not-less bit amount.

Also a last question, what is the advantage of the base32hex (0-9, A-V) over the base32 (A-Z, 2-7) in this case (filename uuid)?

Sorry, don’t know.

slimhk45 commented 2 years ago

But why nanoid chose less then? That's what I don't understand, you have rounded to 21, you should do it to 22 characters then?

ai commented 2 years ago

Sorry, it is mobilization happening in my country. I don’t have resources to remember the math.