sqids / sqids-dotnet

Official .NET port of Sqids. Generate short unique IDs from numbers.

Home Page:https://sqids.org/dotnet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Always decoding, even with random string

espindl opened this issue · comments

var sqids = new SqidsEncoder<long>(new SqidsOptions { Alphabet = _sqidAlphabet });
return sqids.Decode(sqid);

This code always decode, even with random string. But the playground returns Error: Invalid ID with the same string. Am I doing something wrong or missing a very primitive concept?

Behind the scenes, the playground is simply doing id == encode(decode(id)) and if it's not equal, it'll output a user-friendly error.

More info: https://sqids.org/faq#valid-ids

@espindl Also note that this has been explained in the README here as it relates to this particular library.

Yeah, thank you and sorry I missed this in both faq and readme @aradalvand @4kimov