-
Notifications
You must be signed in to change notification settings - Fork 24
Sign Message Example
Jim Schaad edited this page Sep 1, 2016
·
1 revision
This example shows how to create a signed message, attach a signer and then serialize the message to a buffer.
public static void SignAMessage(string ContentToSign) throws CoseException {
// Create the signed message
SignMessage msg = new SignMessage();
// Add the content to the message
msg.SetContent(ContentToSign);
// Create the signer for the message
Signer signer = new Signer();
signer.setKey(signingKey);
signer.addAttribute(HeaderKeys.Algorithm, AlgorithmID.AsCBOR(), Attribute.ProtectedAttributes);
msg.addSigner(signer);
// Force the message to be signed
msg.sign();
// Now serialize out the message
return msg.EncodeToBytes();
}
See Also: Validate Signed Message Example