Пример #1
0
        public static string CreateJwkString(RsaPublicKeyJwk jwk = null)
        {
            if (jwk == null)
            {
                jwk = CreateJwk();
            }

            var json = JsonConvert.SerializeObject(jwk);

            return(Base64Url.Encode(Encoding.ASCII.GetBytes(json)));
        }
Пример #2
0
        public static RsaPublicKeyJwk CreateJwk()
        {
            var prov   = CreateProvider();
            var pubKey = prov.ExportParameters(false);

            var jwk = new RsaPublicKeyJwk("key1")
            {
                kty = "RSA",
                n   = Base64Url.Encode(pubKey.Modulus),
                e   = Base64Url.Encode(pubKey.Exponent)
            };

            return(jwk);
        }