Skip to content
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

Does anyone actually use the SetCharacters method? #18

Closed
bolorundurowb opened this issue Aug 25, 2020 · 6 comments
Closed

Does anyone actually use the SetCharacters method? #18

bolorundurowb opened this issue Aug 25, 2020 · 6 comments
Labels

Comments

@bolorundurowb
Copy link
Owner

If it is not in use, then we can consider removing it in the next major release

@svenbit
Copy link

svenbit commented Aug 26, 2020

I used SetCharacters in one of the project to generate uppercased+number only shortid

string shortIdCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXQYZ1234567890";

ShortId.SetCharacters(shortIdCharacters);

var opts = new GenerationOptions
{
   UseSpecialCharacters = false,
   UseNumbers = true,
   Length = 12
};

ShortId.Generate(opts);

@inexuscore
Copy link

@svenbit This doesn't work, the library throws an InvalidOperationException saying The replacement characters must be at least 50 letters in length and without whitespace. I'd like to generate uppercase letters only + digits. Any ideas?

@bolorundurowb
Copy link
Owner Author

@inexuscore the limitation was added in version 3.0.0 to improve uniqueness of generated ids. If you want to limit the character set then you can use version 2.0.4

@inexuscore
Copy link

@bolorundurowb ah I see, that's what I thought. Thank you very much, I'll stick with the latest version. Better to have more uniqueness than unreliable IDs.

@djordjedjukic
Copy link

@inexuscore I am using something like this:

ShortId.Generate(true, false, 12).Insert(6, "-").ToUpper()

Only numbers. length 12 and dash in the middle.

@inexuscore
Copy link

@djordjedjukic brilliant, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants