Seems like that when decoding input with length smaller than minHashLength the Decode throws System.ArgumentException & System.ArgumentOutOfRangeException exceptions
Expected Behavior
I guess it would be to validate the input before doing a .Decode() and either throw meaningful exception or return empty array
Current Behavior
Currently. the library sometimes throws (undocumented?) System.ArgumentException & System.ArgumentOutOfRangeException exceptions.
Possible Solution
Have a proper validation of the input before doing any actions or something else
Steps to Reproduce
new HashidsNet.Hashids(salt: "Dqa2s3RJBYPHUzg&R5qkF3Z4HLaWp#A^kMc^DqKVmqag2tasQjhz-PSM23=4", minHashLength: 9)
.Decode("5111111")
System.ArgumentException: Destination is too short. (Parameter 'destination')
&
new HashidsNet.Hashids(salt: "Dqa2s3RJBYPHUzg&R5qkF3Z4HLaWp#A^kMc^DqKVmqag2tasQjhz-PSM23=4", minHashLength: 10)
.Decode("5111111")
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Context (Environment)
.NET version: ASP.NET Core 6.0 - basic API controller
Hashids.net version: 1.6.1
StackTrace 1:
System.ArgumentException: Destination is too short. (Parameter 'destination')
at System.Text.StringBuilder.CopyTo(Int32 sourceIndex, Span`1 destination, Int32 count)
at HashidsNet.Hashids.GenerateHashFrom(ReadOnlySpan`1 numbers, Span`1& result)
at HashidsNet.Hashids.GetNumbersFrom(String hash)
at HashidsNet.Hashids.Decode(String hash)
at WebApplication1.Controllers.WeatherForecastsApi2Controller.GetWeatherForecast2()
StackTrace 2:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
at System.Text.StringBuilder.CopyTo(Int32 sourceIndex, Span`1 destination, Int32 count)
at HashidsNet.Hashids.GenerateHashFrom(ReadOnlySpan`1 numbers, Span`1& result)
at HashidsNet.Hashids.GetNumbersFrom(String hash)
at HashidsNet.Hashids.Decode(String hash)
at WebApplication1.Controllers.WeatherForecastsApi2Controller.GetWeatherForecast2()
Possible Implementation
/
Seems like that when decoding input with length smaller than
minHashLengththeDecodethrowsSystem.ArgumentException&System.ArgumentOutOfRangeExceptionexceptionsExpected Behavior
I guess it would be to validate the input before doing a
.Decode()and either throw meaningful exception or return empty arrayCurrent Behavior
Currently. the library sometimes throws (undocumented?)
System.ArgumentException&System.ArgumentOutOfRangeExceptionexceptions.Possible Solution
Have a proper validation of the input before doing any actions or something else
Steps to Reproduce
new HashidsNet.Hashids(salt: "Dqa2s3RJBYPHUzg&R5qkF3Z4HLaWp#A^kMc^DqKVmqag2tasQjhz-PSM23=4", minHashLength: 9).Decode("5111111")System.ArgumentException: Destination is too short. (Parameter 'destination')&
new HashidsNet.Hashids(salt: "Dqa2s3RJBYPHUzg&R5qkF3Z4HLaWp#A^kMc^DqKVmqag2tasQjhz-PSM23=4", minHashLength: 10).Decode("5111111")System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.Context (Environment)
.NET version: ASP.NET Core 6.0 - basic API controller
Hashids.net version: 1.6.1
StackTrace 1:
StackTrace 2:
Possible Implementation
/