renmengye/base62-csharp

Incorrect zero padding on some Guids

Opened this issue · 1 comments

I recognize this project is a number of years old, but I wanted to leave a remark for anyone else coming across this just in case. In some cases, when encoding a Guid, the algorithm will pad an erroneous zero to the end. For example:

Guid: b45a57cd-440a-41f4-b57f-fe87c4fca78e
Expected result: pLTQj0f4yY3QlzzGz4zbF7
Actual result: pLTQj0f4yY3QlzzGz4zbF70

When running a unit test with one million iterations, the algorithm failed a number of times, returning an encoded string with a length of 23 rather than the expected length of 22.

When create the ported version of KSUID for .Net, I found that this project does not return the same result as the PHP or Golang edition, I'm trying to solve this problem now.

For example:

Original Byte Array: {5, 169, 94, 33, 215, 182, 254, 140, 215, 207, 242, 17, 112, 77, 142, 123, 148, 33, 33, 11}
Expected result: 0o5Fs0EELR0fUjHjbCnEtdUwQe3
Actual result: 1QbU8TUszqPhvzo4N1DZdkK8I4B