예제 #1
0
        public void HMACSHA512_2Iterations()
        {
            var serializer = new JwtSerializer(JwtHashAlgorithm.HMACSHA512, 2, SALT);
            var payload    = new Dictionary <string, string>()
            {
                { "test", "test" }
            };

            var jwt = serializer.Serialize(payload);

            payload = serializer.Deserialize(jwt);

            Assert.True(payload.ContainsKey("test"));
            Assert.Equal("test", payload["test"]);
        }
예제 #2
0
        public void TamperingCausesTamperingException()
        {
            var serializer = new JwtSerializer(JwtHashAlgorithm.HMACSHA512, 2, SALT);
            var payload    = new Dictionary <string, string>()
            {
                { "test", "test" }
            };

            var jwt = serializer.Serialize(payload);

            jwt = jwt + "test";

            var e = Assert.Throws <TamperingException>(() => serializer.Deserialize(jwt));

            Assert.Equal("JWT shows signs of tampering.", e.Message);
        }