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)); } }
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()); } }