Exemplo n.º 1
0
        void it_can_decode_from_a_hash_with_a_minimum_length()
        {
            var h = new HashIds(salt, 8);

            h.Decode("gB0NV05e").Should().Equal(new [] { 1 });
            h.Decode("mxi8XH87").Should().Equal(new[] { 25, 100, 950 });
            h.Decode("KQcmkIW8hX").Should().Equal(new[] { 5, 200, 195, 1 });
        }
Exemplo n.º 2
0
        void it_does_not_decode_with_a_different_salt()
        {
            var peppers = new HashIds("this is my pepper");

            _hashIds.Decode("NkK9").Should().Equal(new [] { 12345 });
            peppers.Decode("NkK9").Should().Equal(new int [0]);
        }
Exemplo n.º 3
0
        void issue_15_it_should_return_emtpy_array_when_decoding_characters_missing_in_alphabet()
        {
            var hashids = new HashIds(salt: "Salty stuff", alphabet: "qwerty1234!¤%&/()=", separators: "1234");
            var numbers = hashids.Decode("abcd");

            numbers.Length.Should().Be(0);

            var hashids2 = new HashIds();

            hashids.Decode("13-37").Length.Should().Be(0);
            hashids.DecodeLong("32323kldffd!").Length.Should().Be(0);

            var hashids3 = new HashIds(alphabet: "1234567890;:_!#¤%&/()=", separators: "!#¤%&/()=");

            hashids.Decode("asdfb").Length.Should().Be(0);
            hashids.DecodeLong("asdfgfdgdfgkj").Length.Should().Be(0);
        }
Exemplo n.º 4
0
        void it_decodes_an_encoded_number()
        {
            _hashIds.Decode("NkK9").Should().Equal(new [] { 12345 });
            _hashIds.Decode("5O8yp5P").Should().Equal(new [] { 666555444 });

            _hashIds.Decode("Wzo").Should().Equal(new [] { 1337 });
            _hashIds.Decode("DbE").Should().Equal(new [] { 808 });
            _hashIds.Decode("yj8").Should().Equal(new[] { 303 });
        }
Exemplo n.º 5
0
 void issue_8_should_not_throw_out_of_range_exception()
 {
     var hashids = new HashIds("janottaa", 6);
     var numbers = hashids.Decode("NgAzADEANAA=");
 }