Пример #1
0
        private static string GenerateDkimSignature(Email email, Encoding encoding, IPrivateKeySigner privateKeySigner, string[] headersToSign)
        {
            if (email == null)
            {
                throw new ArgumentNullException("email");
            }

            if (email.Headers == null)
            {
                throw new ArgumentException("email headers property is null");
            }

            var headers = DkimCanonicalizer.CanonicalizeHeaders(email.Headers, dkimHeaderCanonicalization, true, headersToSign);

            // assumes signature ends with "b="
            return(Convert.ToBase64String(privateKeySigner.Sign(encoding.GetBytes(headers), dkimSigningAlgorithm)));
        }
Пример #2
0
        private static string DkimSignBody(string body, Encoding encoding, IPrivateKeySigner privateKeySigner)
        {
            var cb = DkimCanonicalizer.CanonicalizeBody(body, dkimBodyCanonicalization);

            return(Convert.ToBase64String(privateKeySigner.Hash(encoding.GetBytes(cb), dkimSigningAlgorithm)));
        }