public DecryptionTypeEncode() { var rsaParams = RSA.Create().ExportParameters(true); payload = new Payload { hoge = "hugahuga", hage = "nanonano" }; var ehs256 = new LitJWT.JwtEncoder(new LitJWT.Algorithms.HS256Algorithm(LitJWT.Algorithms.HS256Algorithm.GenerateRandomRecommendedKey())); var ehs384 = new LitJWT.JwtEncoder(new LitJWT.Algorithms.HS384Algorithm(LitJWT.Algorithms.HS384Algorithm.GenerateRandomRecommendedKey())); var ehs512 = new LitJWT.JwtEncoder(new LitJWT.Algorithms.HS512Algorithm(LitJWT.Algorithms.HS512Algorithm.GenerateRandomRecommendedKey())); var ers256 = new LitJWT.JwtEncoder(new LitJWT.Algorithms.RS256Algorithm(() => RSA.Create(rsaParams), () => RSA.Create(rsaParams))); var ers384 = new LitJWT.JwtEncoder(new LitJWT.Algorithms.RS384Algorithm(() => RSA.Create(rsaParams), () => RSA.Create(rsaParams))); var ers512 = new LitJWT.JwtEncoder(new LitJWT.Algorithms.RS512Algorithm(() => RSA.Create(rsaParams), () => RSA.Create(rsaParams))); hs256 = new LitJWT.JwtDecoder(ehs256.SignAlgorithm); hs384 = new LitJWT.JwtDecoder(ehs384.SignAlgorithm); hs512 = new LitJWT.JwtDecoder(ehs512.SignAlgorithm); rs256 = new LitJWT.JwtDecoder(ers256.SignAlgorithm); rs384 = new LitJWT.JwtDecoder(ers384.SignAlgorithm); rs512 = new LitJWT.JwtDecoder(ers512.SignAlgorithm); b1 = ehs256.EncodeAsUtf8Bytes(payload, null, (x, writer) => writer.Write(Utf8Json.JsonSerializer.SerializeUnsafe(x))); b2 = ehs384.EncodeAsUtf8Bytes(payload, null, (x, writer) => writer.Write(Utf8Json.JsonSerializer.SerializeUnsafe(x))); b3 = ehs512.EncodeAsUtf8Bytes(payload, null, (x, writer) => writer.Write(Utf8Json.JsonSerializer.SerializeUnsafe(x))); b4 = ers256.EncodeAsUtf8Bytes(payload, null, (x, writer) => writer.Write(Utf8Json.JsonSerializer.SerializeUnsafe(x))); b5 = ers384.EncodeAsUtf8Bytes(payload, null, (x, writer) => writer.Write(Utf8Json.JsonSerializer.SerializeUnsafe(x))); b6 = ers512.EncodeAsUtf8Bytes(payload, null, (x, writer) => writer.Write(Utf8Json.JsonSerializer.SerializeUnsafe(x))); }
public JwtDecode() { key = Encoding.UTF8.GetBytes("hogehogehogehoge"); litJwtDecoder = new LitJWT.JwtDecoder(new LitJWT.JwtAlgorithmResolver(new LitJWT.Algorithms.HS256Algorithm(key))); jwtDecoder = new JWT.JwtDecoder(new JWT.Serializers.JsonNetSerializer(), new JWT.JwtValidator(new JWT.Serializers.JsonNetSerializer(), new UtcDateTimeProvider()), new JWT.JwtBase64UrlEncoder()); jwtHandler = new JwtSecurityTokenHandler() { SetDefaultTimesOnTokenCreation = false }; handlerKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(key); tokenA = new JwtEncode().LitJwt(); tokenB = new JwtEncode().JwtDotNet(); tokenC = new JwtEncode().MicrosoftIdentityModelJwt(); }