示例#1
0
        /// <summary>
        /// Creates a signature for the specified text
        /// but does not embed it into the text.
        /// </summary>
        /// <param name="signer">The <see cref="ISigner"/>
        /// instance that is used to generate the signature.</param>
        /// <param name="text">The text for which to generate a signature.</param>
        /// <param name="privateKey">The private key for signing the text.</param>
        /// <returns>The signature block, which can be placed alongside
        /// or within the text.</returns>
        /// <exception cref="ArgumentNullException">
        /// Occurs if any of the arguments are null.</exception>
        public async Task <string> CreateButDoNotEmbedSignatureAsync(
            ISigner signer, string text, string privateKey)
        {
            AssertArg.IsNotNull(signer, nameof(signer));
            AssertArg.IsNotNull(text, nameof(text));
            AssertArg.IsNotNull(privateKey, nameof(privateKey));

            string signatureText = await signer.CreateBase64SignatureAsync(text, privateKey, Encoding);

            string result = $"<![CDATA[{SignatureIndicator}{signatureText}]]>";

            return(result);
        }