void issue_14_it_should_decode_encode_hex_correctly() { var hashids = new Hashids("this is my salt"); var encoded = hashids.EncodeHex("DEADBEEF"); encoded.Should().Be("kRNrpKlJ"); var decoded = hashids.DecodeHex(encoded); decoded.Should().Be("DEADBEEF"); var encoded2 = hashids.EncodeHex("1234567890ABCDEF"); var decoded2 = hashids.DecodeHex(encoded2); decoded2.Should().Be("1234567890ABCDEF"); }
public void HexString_Encode() { _hashids.EncodeHex("FA").Should().Be("lzY"); _hashids.EncodeHex("26dd").Should().Be("MemE"); _hashids.EncodeHex("FF1A").Should().Be("eBMrb"); _hashids.EncodeHex("12abC").Should().Be("D9NPE"); _hashids.EncodeHex("185b0").Should().Be("9OyNW"); _hashids.EncodeHex("17b8d").Should().Be("MRWNE"); _hashids.EncodeHex("1d7f21dd38").Should().Be("4o6Z7KqxE"); _hashids.EncodeHex("20015111d").Should().Be("ooweQVNB"); }
void it_encode_hex_string() { hashids.EncodeHex("FA").Should().Be("lzY"); hashids.EncodeHex("26dd").Should().Be("MemE"); hashids.EncodeHex("FF1A").Should().Be("eBMrb"); hashids.EncodeHex("12abC").Should().Be("D9NPE"); hashids.EncodeHex("185b0").Should().Be("9OyNW"); hashids.EncodeHex("17b8d").Should().Be("MRWNE"); hashids.EncodeHex("1d7f21dd38").Should().Be("4o6Z7KqxE"); hashids.EncodeHex("20015111d").Should().Be("ooweQVNB"); }
public void HexString_Roundtrip() { var hashids = new Hashids("this is my salt"); var encoded = hashids.EncodeHex("DEADBEEF"); encoded.Should().Be("kRNrpKlJ"); var decoded = hashids.DecodeHex(encoded); decoded.Should().Be("DEADBEEF"); var input2 = "1234567890ABCDEF"; var decoded2 = hashids.DecodeHex(hashids.EncodeHex(input2)); decoded2.Should().Be(input2); }
public string HashValue(string id) { var hexValue = StringToHex(id).Replace("-", ""); return(_hashIds.EncodeHex(hexValue)); }
public string GenerateEncodedUserEmail(string email) { var hexEmail = string.Join("", email.Select(c => ((int)c).ToString("X2"))); return(_hashedId.EncodeHex(hexEmail)); }