Skip to content

Commit 98d7e56

Browse files
authored
Fixed invalid constant for long length (#66)
Fixes #64
1 parent 1d574f6 commit 98d7e56

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/Hashids.net/Hashids.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public partial class Hashids : IHashids
1616

1717
private const double SEP_DIV = 3.5;
1818
private const double GUARD_DIV = 12.0;
19-
private const int MaxNumberHashLength = 12; // Length of long.MaxValue;
19+
private const int MaxNumberHashLength = 19; // Length of long.MaxValue;
2020

2121
private readonly char[] _alphabet;
2222
private readonly char[] _seps;

test/Hashids.net.test/IssueSpecificTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,18 @@ void issue_15_it_should_return_emtpy_array_when_decoding_characters_missing_in_a
5252
hashids.Decode("asdfb").Length.Should().Be(0);
5353
hashids.DecodeLong("asdfgfdgdfgkj").Length.Should().Be(0);
5454
}
55+
56+
[Fact]
57+
void issue_64_it_should_be_possible_to_encode_and_decode_long_max_value()
58+
{
59+
var hashids = new Hashids("salt", alphabet: "0123456789ABCDEF");
60+
var hash = hashids.EncodeLong(long.MaxValue);
61+
62+
hash.Should().Be("58E9BDD9A7598254DA4E");
63+
64+
var decoded = hashids.DecodeSingleLong(hash);
65+
66+
decoded.Should().Be(long.MaxValue);
67+
}
5568
}
5669
}

0 commit comments

Comments
 (0)