예제 #1
0
        public bool Verify(string payload, byte[] signature, JsonWebKey jsonWebKey)
        {
            var plainBytes = ASCIIEncoding.ASCII.GetBytes(payload);

            using (var dsa = new ECDsaCng())
            {
                dsa.HashAlgorithm = CngHashAlg;
                dsa.Import(jsonWebKey.Content);
                return(dsa.VerifyData(plainBytes, signature, HashAlg));
            }
        }
예제 #2
0
        public string Sign(string payload, JsonWebKey jsonWebKey)
        {
            var bytesToBeSigned = ASCIIEncoding.ASCII.GetBytes(payload);

            using (var dsa = new ECDsaCng())
            {
                dsa.HashAlgorithm = CngHashAlg;
                dsa.Import(jsonWebKey.Content);
                return(dsa.SignData(bytesToBeSigned, HashAlg).Base64EncodeBytes());
            }
        }